Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clarify insert/race condition error message #40

Merged
merged 2 commits into from
May 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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