I have few instances of my application, from each instance we have a single thread that picks a unprocessed item from a MySql table, and starts processing it. The table structure is as follows:
id | status | other_params
| |
| |
'status' field will denotes whether the entry is processed or not.
I am facing issues as to how, I will ensure that when one instance/thread picks up an entry from the table, no other thread picks that entry for processing.
I have thought of solution about changing the status to 'PROCESSING' and to 'PROCESSED' when done, but for the change to be visible to other threads, I need to commit. And if the node processing the request fails, it would always be 'PROCESSING'.
Also the operation is an heavy operation, so I don't want more than one thread to do the task.
Any ideas someone can provide will be helpful.