Concurrency problem for claim mechanism
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
zaqar |
Invalid
|
Undecided
|
Unassigned |
Bug Description
At present, zaqar's claim mechanism allows users to exclusively obtain messages in the queue, that is, the message can only be obtained once in a while. This exclusive cycle is defined using claim ttl. In this cycle, the message can only be claimed once.
But when I was doing the concurrency test, I found that the message could be claimed multiple times at the same time. The probability of such a situation is very small, dozens of tests may occur once.
So, I looked at zaqar's source code for the claim section. When zaqar is processing the claim, it first gets a batch of messages that can be used for the claim, and then updates the metadata of the messages about the claim, including the claim expiration time, the claim id, and so on. Then through the id to get the message and return.
The above steps have 3 processing mongodb process, but this process is not locked, it will lead to concurrency problems. So I think here need a lock mechanism, locked in the first step, unlocked after the second update of the database, and the lock will expire, to prevent deadlock.
Changed in zaqar: | |
assignee: | nobody → yangzhenyu (cdyangzhenyu) |
Changed in zaqar: | |
status: | New → Invalid |
assignee: | yangzhenyu (cdyangzhenyu) → nobody |
hmm... May I know why it's tagged as 'Invalid'? Is it still a problem?