Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Worker may have a race-condition when accepting work #6

Open
drigz opened this issue Dec 15, 2014 · 2 comments
Open

Worker may have a race-condition when accepting work #6

drigz opened this issue Dec 15, 2014 · 2 comments

Comments

@drigz
Copy link
Owner

drigz commented Dec 15, 2014

I'm not sure how rowcount is set, so when Worker goes to update a work item as being taken by it, it assumes that of two concurrent executions of:

UPDATE uploaded SET state=1 WHERE state=0 AND id=1;
COMMIT;

after the commit, one cursor will have rowcount=1 and one will have rowcount=0. However, this may not be true, but I'm not sure how to correctly implement a queue removal like this in SQL, or even if it's a sensible thing to try.

An alternative would be to use Python's multiprocessing.Queue, but this is not particularly important while load is low...

@drigz
Copy link
Owner Author

drigz commented Dec 15, 2014

Hmmm, rowcount is definitely not safe:

If a separate thread makes changes on the same database connection while sqlite3_changes() is running then the value returned is unpredictable and not meaningful.

@drigz
Copy link
Owner Author

drigz commented Dec 15, 2014

"column restrictions" may help for this, whatever they are.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant