glucinater
glucinater11mo ago

db.insert and db.get in succession not working

I am currently doing adding data to convex using a python script I created that calls a function. Part of the function will insert a row into the database and schedule another function that uses the row I just created. However I occasionally get an error that that indicates the row was not found. Code used is attached (a bit long)
6 Replies
glucinater
glucinaterOP11mo ago
This is the log, it rarely fails but it has enough times to concern me
lee
lee11mo ago
Is it possible that insertInstanceAndCourse is being called twice with the same args.Class_Number ? Each time you call it, any existing instance with that class number will be deleted and a new one created, and a scheduled job is scheduled. If it runs twice in succession, the first scheduled job might run after the instance has already been deleted by the second insertInstanceAndCourse
glucinater
glucinaterOP11mo ago
hm i dont think so but I can try semester as an additional constraint because that should definiteltly be globally unique still occasionally appearing
glucinater
glucinaterOP11mo ago
for some more context this is the script I am running. The convex calls are done synchrounosly in a forloop
lee
lee11mo ago
Some things i would try: - comment out the ctx.db.delete(oldInstanceId) or move it to the scheduled mutation and see if the issue goes away. - console.log the newInstanceId after creation and in the scheduled mutation, and the oldInstanceId when it gets deleted. - check the file to see if there are duplicate course numbers. - check if other mutations are potentially deleting instances. If a mutation is really only partially committing, that would be a bad bug in Convex. So it would be great to boil down a repro by removing confounding factors like race conditions between the delete and the scheduled function.
glucinater
glucinaterOP11mo ago
trying that out, on an unrelated note are there any ways to avoid "connection reset by peer" exceptions when using python api? Also it looks like there were duplicate values, guessing due to human input errorss looks like that was the erro, thanks for the help

Did you find this page helpful?