Skip to content

Listen/Unlisten race in Pubsub #15312

Closed
Closed
@spikecurtis

Description

@spikecurtis

spotted while reviewing #15303

In the Pubsub, we can't hold the qMu lock while calling Listen or Unlisten on the pgListener, 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 calling Listen and Unlisten, these could happen in any order. If Unlisten is called last, the new subscriber won't get any events.

Metadata

Metadata

Assignees

Labels

s2Broken use cases or features (with a workaround). Only humans may set this.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions