- Notifications
You must be signed in to change notification settings - Fork926
Description
spotted while reviewing#15303
In thePubsub, we can't hold theqMu
lock while callingListen
orUnlisten
on thepgListener
, because this lock is also held while delivering notifications. This was the source of a Pubsub deadlock (#11950) that we fixed in#12518. However, that fix leaves us with a new race condition that goes like this:
We have a single subscriber to some event, and they cancel their subscription. Concurrently, we get a new Subscribe call for the same event. Since we don't hold a lock while callingListen
andUnlisten
, these could happen in any order. IfUnlisten
is called last, the new subscriber won't get any events.