-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: provide a more precise detection of empty state in MPSCIntrusive…
…Queue The scenario is around remote fiber activation. And it goes like this: 1. A fiber is blocked on EventCount.wait_until (i.e. timed wait) 2. The fiber times outs but in parallel another thread sends it a notification via the remote queue. 3. EventCount::wait_until tries to pull itself from the remote queue, but does not find itself there, even though the notification was pushed STRICTLY BEFORE `active->PullMyselfFromRemoteReadyQueue()` call. We know it because the notify call is under the EventCount spinlock, and PullMyselfFromRemoteReadyQueue is done after the spinlock was grabbed and released. The scenario happens when, the remote queue is empty but then something else tries to notify another, unrelated fiber in the thread, but does not finish crossing the blocking point (*). Then our fiber had notification being pushed into the queue. Then our fiber is waked by the timeout and it tries to pull itself from the queue just to learn the queue is empty, which contradicts the fact we observed BEFORE relationship between notify and PullMyselfFromRemoteReadyQueue call due to the spinlock in EventCount. This fix recognizes the stuck in the middle push by loading the tail and comparing it with head. Signed-off-by: Roman Gershman <[email protected]>
- Loading branch information
Showing
3 changed files
with
43 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters