Skip to content

Add tests for rabbit_classic_queue_index_v2:bounds/2#13932

Merged
michaelklishin merged 2 commits intorabbitmq:mainfrom
cloudamqp:cq_index_v2_bounds_test
May 23, 2025
Merged

Add tests for rabbit_classic_queue_index_v2:bounds/2#13932
michaelklishin merged 2 commits intorabbitmq:mainfrom
cloudamqp:cq_index_v2_bounds_test

Conversation

@gomoripeti
Copy link
Copy Markdown
Contributor

Proposed Changes

This is a follow up to #13856 to cover the newly added rabbit_classic_queue_index_v2:bounds/2 with tests.

Types of Changes

What types of changes does your code introduce to this project?
Put an x in the boxes that apply

  • Bug fix (non-breaking change which fixes issue #NNNN)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause an observable behavior change in existing systems)
  • Documentation improvements (corrections, new content, etc)
  • Cosmetic change (whitespace, formatting, etc)
  • Build system and/or CI

Checklist

Put an x in 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.

  • I have read the CONTRIBUTING.md document
  • I have signed the CA (see https://cla.pivotal.io/sign/rabbitmq)
  • I have added tests that prove my fix is effective or that my feature works
  • All tests pass locally with my changes
  • If relevant, I have added necessary documentation to https://github.com/rabbitmq/rabbitmq-website
  • If relevant, I have added this change to the first version(s) in release-notes that I expect to introduce it

Further 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.

@michaelklishin michaelklishin added this to the 4.2.0 milestone May 23, 2025
@michaelklishin michaelklishin merged commit bf8fd69 into rabbitmq:main May 23, 2025
536 of 540 checks passed
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.
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.

2 participants