Add tests for rabbit_classic_queue_index_v2:bounds/2#13932
Merged
michaelklishin merged 2 commits intorabbitmq:mainfrom May 23, 2025
Merged
Add tests for rabbit_classic_queue_index_v2:bounds/2#13932michaelklishin merged 2 commits intorabbitmq:mainfrom
michaelklishin merged 2 commits intorabbitmq:mainfrom
Conversation
michaelklishin
approved these changes
May 23, 2025
12 tasks
michaelklishin
added a commit
that referenced
this pull request
May 23, 2025
Add tests for rabbit_classic_queue_index_v2:bounds/2 (backport #13932)
lukebakken
added a commit
to lukebakken/rmq-rabbitmq-server
that referenced
this pull request
Mar 17, 2026
…tibility fixes This commit cherry-picks PR rabbitmq#13932 (bf8fd69, 'Add tests for rabbit_classic_queue_index_v2:bounds/2') and applies the additional changes required to make it correct in 3.13.7, where the v1 index (`rabbit_queue_index`) still exists alongside the v2 index. PR rabbitmq#13932 in upstream main: - Removed the `bounds/1` shim from `rabbit_classic_queue_index_v2` (which had been added by PR rabbitmq#13856 as a compatibility wrapper) - Updated test call sites in `backing_queue_SUITE` from `IndexMod:bounds(Qi)` to `IndexMod:bounds(Qi, Hint)` Why the cherry-pick alone was insufficient for 3.13.7: In upstream main, the v1<->v2 index conversion code in `rabbit_variable_queue` and `rabbit_queue_index` had already been removed by commit ecf4600 ('Remove availability of CQv1', March 2024) before PR rabbitmq#13856 introduced `bounds/2` (May 2025). Therefore, when PR rabbitmq#13932 removed the `bounds/1` shim, there were no production call sites left that used the 1-argument form. In 3.13.7, the v1<->v2 conversion code still exists. Two production call sites were left calling the now-deleted `bounds/1`: - `rabbit_variable_queue:convert_from_v2_to_v1` called `rabbit_classic_queue_index_v2:bounds(V2Index)` - `rabbit_queue_index:recover_index_v2_common` called `rabbit_classic_queue_index_v2:bounds(V2State)` Both crashed at runtime with `{undef, {rabbit_classic_queue_index_v2, bounds, [...]}` when a queue version downgrade (v2->v1) was attempted, as exercised by `classic_queue_prop_SUITE`. Changes in this commit beyond the cherry-pick: 1. `rabbit_queue_index.erl`: Added `bounds/2` with the same `NextSeqIdHint` logic as PR rabbitmq#13856 applied to `rabbit_classic_queue_index_v2`. When `SegNums = []` (no segment files) and `NextSeqIdHint` is an integer, returns `{Hint, Hint, State}` instead of `{0, 0, State}`. The existing `bounds/1` is kept as a shim delegating to `bounds(State, undefined)`. Also updated the internal call to `rabbit_classic_queue_index_v2:bounds` in `recover_index_v2_common` to use `bounds/2`. 2. `rabbit_variable_queue.erl`: Updated the call in `convert_from_v2_to_v1` to `rabbit_classic_queue_index_v2:bounds/2`. Also simplified the `IndexMod:bounds` dispatch in `init/10` from a case expression (routing v2 to `bounds/2` and v1 to `bounds/1`) to a single `IndexMod:bounds(IndexState, NextSeqIdHint)` call, since both index modules now implement `bounds/2`. 3. `backing_queue_SUITE.erl`: Removed the comment block that had previously disabled `variable_queue_restart_large_seq_id` for the `backing_queue_v1` suite. With `rabbit_queue_index:bounds/2` now implemented, the fix is complete for both v1 and v2 queues and the test passes for both. Validation: `backing_queue_SUITE` (all groups including `backing_queue_v1` and `backing_queue_v2`) and `classic_queue_prop_SUITE` (6/6 tests) both pass cleanly.
lukebakken
added a commit
to lukebakken/rmq-rabbitmq-server
that referenced
this pull request
Mar 17, 2026
…tibility fixes This commit cherry-picks PR rabbitmq#13932 (bf8fd69, 'Add tests for rabbit_classic_queue_index_v2:bounds/2') and applies the additional changes required to make it correct in 3.13.7, where the v1 index (`rabbit_queue_index`) still exists alongside the v2 index. PR rabbitmq#13932 in upstream main: - Removed the `bounds/1` shim from `rabbit_classic_queue_index_v2` (which had been added by PR rabbitmq#13856 as a compatibility wrapper) - Updated test call sites in `backing_queue_SUITE` from `IndexMod:bounds(Qi)` to `IndexMod:bounds(Qi, Hint)` Why the cherry-pick alone was insufficient for 3.13.7: In upstream main, the v1<->v2 index conversion code in `rabbit_variable_queue` and `rabbit_queue_index` had already been removed by commit ecf4600 ('Remove availability of CQv1', March 2024) before PR rabbitmq#13856 introduced `bounds/2` (May 2025). Therefore, when PR rabbitmq#13932 removed the `bounds/1` shim, there were no production call sites left that used the 1-argument form. In 3.13.7, the v1<->v2 conversion code still exists. Two production call sites were left calling the now-deleted `bounds/1`: - `rabbit_variable_queue:convert_from_v2_to_v1` called `rabbit_classic_queue_index_v2:bounds(V2Index)` - `rabbit_queue_index:recover_index_v2_common` called `rabbit_classic_queue_index_v2:bounds(V2State)` Both crashed at runtime with `{undef, {rabbit_classic_queue_index_v2, bounds, [...]}` when a queue version downgrade (v2->v1) was attempted, as exercised by `classic_queue_prop_SUITE`. Changes in this commit beyond the cherry-pick: 1. `rabbit_queue_index.erl`: Added `bounds/2` with the same `NextSeqIdHint` logic as PR rabbitmq#13856 applied to `rabbit_classic_queue_index_v2`. When `SegNums = []` (no segment files) and `NextSeqIdHint` is an integer, returns `{Hint, Hint, State}` instead of `{0, 0, State}`. The existing `bounds/1` is kept as a shim delegating to `bounds(State, undefined)`. Also updated the internal call to `rabbit_classic_queue_index_v2:bounds` in `recover_index_v2_common` to use `bounds/2`. 2. `rabbit_variable_queue.erl`: Updated the call in `convert_from_v2_to_v1` to `rabbit_classic_queue_index_v2:bounds/2`. Also simplified the `IndexMod:bounds` dispatch in `init/10` from a case expression (routing v2 to `bounds/2` and v1 to `bounds/1`) to a single `IndexMod:bounds(IndexState, NextSeqIdHint)` call, since both index modules now implement `bounds/2`. 3. `backing_queue_SUITE.erl`: Removed the comment block that had previously disabled `variable_queue_restart_large_seq_id` for the `backing_queue_v1` suite. With `rabbit_queue_index:bounds/2` now implemented, the fix is complete for both v1 and v2 queues and the test passes for both. Validation: `backing_queue_SUITE` (all groups including `backing_queue_v1` and `backing_queue_v2`) and `classic_queue_prop_SUITE` (6/6 tests) both pass cleanly.
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
This is a follow up to #13856 to cover the newly added
rabbit_classic_queue_index_v2:bounds/2with tests.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.
If you're unsure about any of them, don't hesitate to ask on the mailing list.
We're here to help!
This is simply a reminder of what we are going to look for before merging your code.
CONTRIBUTING.mddocumentFurther Comments
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution
you did and what alternatives you considered, etc.