fix(stream): keep pending counters consistent - #3596
Draft
wengsht wants to merge 1 commit into
Draft
Conversation
wengsht
force-pushed
the
fix-stream-pending-accounting
branch
2 times, most recently
from
August 18, 2026 21:18
7368c48 to
4a48cae
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Keeps stream PEL counters consistent across acknowledgment and claim operations.
Changes:
- Deduplicates XACK and XCLAIM IDs.
- Corrects ownership accounting and saturates decrements.
- Refreshes XAUTOCLAIM delivery timestamps and adds regressions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/types/redis_stream.cc |
Corrects pending-counter and claim behavior. |
tests/gocase/unit/type/stream/stream_test.go |
Adds stream command regressions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+488
to
+490
| if (!pel_entry.consumer_name.empty() && pel_entry.consumer_name != consumer_name) { | ||
| original_consumer_decrements[pel_entry.consumer_name] += 1; | ||
| consumer_metadata.pending_number += 1; |
Comment on lines
449
to
+451
| for (const auto &id : entry_ids) { | ||
| if (!seen.insert(id).second) { | ||
| continue; |
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.
Problem
Stream pending counters can diverge from the real PEL and wrap past
INT64_MAX, makingXINFO GROUPSandXINFO CONSUMERSundecodable.Three related command behaviors cause or amplify the divergence:
XACK key group id idreads the same PEL record twice from one snapshot, reports two acknowledgements, deletes one record, and decrements the cached group/consumer counters twice.XAUTOCLAIMreturns an expired entry already owned by the target consumer without refreshing its delivery time. Repeating the command returns the same ID again.XCLAIMto the current consumer decrements and increments the same consumer through separate metadata writes; the final write increments its cached pending count.Together, a reclaim loop can produce multiple deliveries of one ID, a client can coalesce those duplicate IDs into one
XACK, and the unsigned counters underflow.Minimal reproduction before this patch:
Change
XACKandXCLAIM.XCLAIMownership decrements per original consumer.XCLAIMownership accounting neutral.XAUTOCLAIMdelivery time for every claimed entry, including entries already owned by the target consumer; preserveJUSTIDretry-count semantics.Tests
Command-level regressions verify:
Validation:
./x.py format./x.py check format./x.py build build-make --unittest -j 8./x.py check tidycould not run locally becauserun-clang-tidyis not installed.AI assistance was used for diagnosis and drafting; I reviewed the code, reproduction, and tests.