Answer the question
In order to leave comments, you need to log in
How to lock a row in mysql?
Hello
I am writing a project with an asynchronous queue.
I'm thinking of using a mysql table like
Id | worker's answer
Accordingly, the question is how to give each task to only one worker - I think that it is a write lock and I see two options:
Add a column with a state of 0/1, but I'm afraid that two or more workers will have time to grab / update the row
Is it possible to lock the row for writing / reading and carianth is most kosher
Thank you
Answer the question
In order to leave comments, you need to log in
It would be more correct to make the workers accept the task from the master process than they themselves would take the task from the database.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question