Ensure archive groups only act on a fixed number of rows - #5939
Merged
Merged
Conversation
johnsimons
approved these changes
Oct 1, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: Particular/ServicePulse#3126
Problem
Failure-group Delete (archive) could show a negative remaining-message count when batches processed more messages than the count captured at the start. EF Core repeatedly queried the live group until it found a short batch, so messages arriving under sustained load could extend the operation indefinitely. RavenDB uses fixed batches, but its group count and batch contents come from separate indexes and can disagree. Restore (unarchive) has the same progress arithmetic. EF Core also counted fetched IDs as processed even when a row changed status before the bulk update.
Change
Behavior and constraints
The operation processes a bounded number of live batches, not a snapshot of IDs. Messages that arrive during processing—and possibly some original members—can remain in the group for a subsequent operation. RavenDB's fixed batch loop is unchanged: reconciling the count prevents negative progress but does not process extra batches when its count and batch indexes differ. On completion, the existing finalization behavior reports the operation complete; batch events and per-message audit entries still use fetched IDs, which can include IDs skipped by the status recheck.
We chose to reconcile the operation's total rather than clamp only the displayed remaining count, because clamping would conceal a mismatch while leaving the operation's persisted totals inconsistent. We bounded EF Core's existing live-batch approach rather than materializing a snapshot of all message IDs, because leaving late arrivals for a later operation is acceptable.
Verification