Skip to content

[DB-1912] Persistent subscriptions: Fix wrong checkpoint when using pinned strategy#5497

Open
shaan1337 wants to merge 2 commits intomasterfrom
shaan1337/fix-wrong-ps-checkpoint
Open

[DB-1912] Persistent subscriptions: Fix wrong checkpoint when using pinned strategy#5497
shaan1337 wants to merge 2 commits intomasterfrom
shaan1337/fix-wrong-ps-checkpoint

Conversation

@shaan1337
Copy link
Member

Persistent subscription consumer strategies that can skip events can produce wrong checkpoints when events are skipped. The pinned consumer strategy is currently the only strategy that can skip events.

This PR fixes the following issues:

  • The logic for assigning sequence numbers / previous event positions to OutstandingMessage did not take skipped events into consideration - this could result into wrongly assigned sequence numbers / previous event positions and subsequently to wrong checkpoints too.
  • The checkpointing mechanism only considers messages in the retry list but skipped events were left in the buffer - this could also result into wrong checkpoints.

@shaan1337 shaan1337 force-pushed the shaan1337/fix-wrong-ps-checkpoint branch 2 times, most recently from 3ffd0b0 to e2ee35c Compare February 9, 2026 09:34
Co-Authored-By: Timothy Coleman <timothy.coleman@gmail.com>
@shaan1337 shaan1337 force-pushed the shaan1337/fix-wrong-ps-checkpoint branch 2 times, most recently from d336daa to 84ef7ea Compare February 9, 2026 11:41
… the consumer strategy skips events

* When a consumer strategy skips an event, don't keep it in the buffer but add it to the retry list instead.
The checkpointing mechanism considers the lowest message in `_retry` - not the lowest message in `_buffer`.
Thus leaving it in the buffer may result in a wrong checkpoint being produced.

* Always update the last known event when a new sequence number has been assigned
A new sequence number being assigned means that we are seeing an event that was not processed before.
In other words, it's the last event we've read from the source stream,
so we update the last known sequence number / last known event position accordingly
@shaan1337 shaan1337 force-pushed the shaan1337/fix-wrong-ps-checkpoint branch from 84ef7ea to a0ce7ec Compare February 10, 2026 06:05
@shaan1337 shaan1337 changed the title Persistent subscriptions: Fix wrong checkpoint when using pinned strategy [DB-1912] Persistent subscriptions: Fix wrong checkpoint when using pinned strategy Feb 10, 2026
@linear
Copy link

linear bot commented Feb 10, 2026

@shaan1337 shaan1337 marked this pull request as ready for review February 10, 2026 06:08
@shaan1337 shaan1337 requested a review from a team as a code owner February 10, 2026 06:08
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