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.
I found this question too simple. Set a key with an expiration time of 60 seconds. Check whether this key exists every time