The program goes to the database to read 10 run_status=0 data every time,
When a task is executed, the database updates fields
run_status=-1
indicates that this task is locked.
Of course, after the task execution is completed, run_status=0, indicating that the lock has been unlocked.
Now comes the problem. When executing a task, due to some exception, such as the server suddenly interrupting the program during publishing, run_status=-1 will always be in the locked state. But it's not actually being implemented.
Now you need to design a mechanism to prevent this from happening. What will you do? The current environment can use redis.
曾经蜡笔没有小新2017-06-26 10:51:39
I found this question too simple. Set a key with an expiration time of 60 seconds. Check whether this key exists every time