Created
September 25, 2014 11:41
-
-
Save hagbarddenstore/5dedd511fcc342aab710 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Tasks are recieved on the "tasks"-queue. | |
2. A worker dequeues a task. | |
3. The worker locks the entity related to the task. | |
4. The worker executes the task with the given entity. | |
5. The worker releases the locked entity. | |
In step 2, if the entity is already locked, the worker should put the task | |
back on the queue and take another task. The problem is, I can't simply | |
enqueue the task, since that will fuck up the ordering. | |
Example, all tasks needs entity Entity A. | |
Task A, Task B, Task C, Task D | |
Worker 1 dequeues Task A, locks Entity A | |
Worker 2 dequeues Task B, sees that Entity A is locked, enqueues Task B | |
again. | |
Now the order is Task C, Task D, Task B. | |
What I want to do, is to put Task B back in it's original place. | |
In short, the workers should dequeue a task where the entity isn't locked. | |
The workers are placed in different physical hosts. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment