Skip to content

Fix race condition in subscription/listen - #1327

Merged
Kehrlann merged 1 commit into
mainfrom
dgarnier/fix-listen-ack-race
Nov 10, 2026
Merged

Kehrlann merged 1 commit into
mainfrom
dgarnier/fix-listen-ack-race

Conversation

@Kehrlann

Copy link
Copy Markdown
Contributor

Under highly contentious load, there might be a race condition in subscription/listen. Every change broadcast before subscribing to the change feed is lost. Subscription happens on a thread, and writing to the wire happens in another thread.

The ack might be fully written to the transport, and received by the client, before the changes are subscribed to.
A test harness might fire a change right after the test client receives ack, but before the changes are subscribed to, and therefore the change is lost.

So we need to ensure that:

  1. Changes are subscribed to BEFORE the ack
  2. But the ACK goes first in any case (and only once)

This is mostly a test-harness fix rather than a real-world scenario.

Under highly contentious load, there might be a race condition in subscription/listen.
Every change broadcast before subscribing to the change feed is lost.
Subscription happens on a thread, and writing to the wire happens in another thread.

The `ack` might be fully written to the transport, and received by the client,
before the changes are subscribed to.
A test harness might fire a change right after the test client receives `ack`,
but before the changes are subscribed to, and therefore the change is lost.

So we need to ensure that:
1. Changes are subscribed to BEFORE the ack
2. But the ACK goes first in any case (and only once)

This is mostly a test-harness fix rather than a real-world scenario.

Signed-off-by: Daniel Garnier-Moiroux <[email protected]>
@Kehrlann Kehrlann changed the title Fix race condition in subscription/listen Fix race condition in subscription/listen Nov 10, 2026
@Kehrlann
Kehrlann merged commit 14fd7ed into main Nov 10, 2026
27 checks passed
@Kehrlann
Kehrlann deleted the dgarnier/fix-listen-ack-race branch November 10, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant