Skip to content

Commit

Permalink
clarify insert/race condition error message (#40)
Browse files Browse the repository at this point in the history
* clarify insert/race condition error message

* clarify node message
  • Loading branch information
cmelone authored May 8, 2024
1 parent adfe25a commit 0965e06
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions gantry/clients/db/insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ async def insert_node(db: aiosqlite.Connection, node: dict) -> int:
pk = await get_node(db, node["uuid"])

if pk is None:
logger.error(f"node not inserted: {node}. data is likely missing")
logger.error(
f"node not inserted: {node}. either a duplicate insert was attempted,\
or the insert failed due to missing data"
)

return pk

Expand All @@ -66,11 +69,15 @@ async def insert_job(db: aiosqlite.Connection, job: dict) -> int:
job,
# if the job somehow gets added into the db (pod+id being unique)
# then ignore the insert
# in this case, lastrowid will be 0
ignore=True,
)
) as cursor:
if cursor.rowcount > 0:
return cursor.lastrowid

logger.error(f"job not inserted: {job}. data is likely missing")
logger.error(
f"job not inserted: {job}. either a duplicate insert was attempted,\
or the insert failed due to missing data"
)
return None

0 comments on commit 0965e06

Please sign in to comment.