Repository navigation
CQ: Count each recovered shared message store reference once - #17351
Merged
Merged
Conversation
count_msg_refs/3 registers references with ets:update_counter/4 and a default object carrying ref_count=1. The increment is applied to a freshly inserted default as well, so every message came out of dirty recovery with one reference too many. That reference was never released: after a crash, every message that was in the store at the time stayed on disk for good, with its index entry, once all queues had consumed it. Fan-out messages were affected the same way (N queues gave N+1 references). Start the default at 0. Add a regression test, and make msg_store_v1_compat remove each message once, as its second remove of a zero-reference entry now crashes the store the way it would in production.
|
Tick the box to add this pull request to the merge queue (same as
|
Contributor
There was a problem hiding this comment.
π’ Approval recommended
The focused fix matches ets:update_counter/4 semantics and is covered by appropriate recovery tests.
Pull request overview
Fixes dirty recovery so each shared message-store reference is counted exactly once.
Changes:
- Initializes recovered reference counters at zero before incrementing
- Adds regression coverage for single and fan-out references
- Updates legacy compatibility expectations
File summaries
| File | Description |
|---|---|
deps/rabbit/src/rabbit_msg_store.erl |
Corrects recovered reference counting |
deps/rabbit/test/backing_queue_SUITE.erl |
Adds regression coverage and updates compatibility tests |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
π‘ Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
|
Thank you!! |
4 of 12 tasks
Contributor
|
Did manual backport in #17354 |
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.
Proposed Changes
There was a bug in the CQ shared message store, the recovery process after an unclean shutdown counted every live message one too many, when it goes through every per-queue index to look for shared messages that are still referenced by any queue.
Bug introduced in commit 18acc01 included in 4.0.0
Details:
rabbit_msg_store:count_msg_refs/3registers references withets:update_counter/4and a default object carrying ref_count=1. The increment is applied to a freshly inserted default as well, so every message came out of dirty recovery with one reference too many. That reference was never released: after a crash, every message that was in the store at the time stayed on disk for good, with its index entry, once all queues had consumed it. Fan-out messages were affected the same way (N queues gave N+1 references).Start the default at 0. Add a regression test, and make msg_store_v1_compat remove each message once, as its second remove of a zero-reference entry now crashes the store the way it would in production.
Types of Changes
What types of changes does your code introduce to this project?
Put an
xin the boxes that applyChecklist
Put an
xin the boxes that apply.You can also fill these out after creating the PR.
This is simply a reminder of what we are going to look for before merging your code.
CONTRIBUTING.mddocumentFurther Comments