Skip to content

Add rabbitmq-streams reset_offset command #14170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 1, 2025
Merged

Conversation

acogoluegnes
Copy link
Contributor

@acogoluegnes acogoluegnes commented Jul 1, 2025

A user can set the stored offset for a stream/reference couple to 0. This way a consumer can keep the same name and re-attach to the beginning of a stream.

References #14124

@acogoluegnes acogoluegnes added this to the 4.2.0 milestone Jul 1, 2025
@acogoluegnes
Copy link
Contributor Author

Acceptance test:

Clone the repository and run the broker on the branch:

cd /tmp
git clone git@github.com:rabbitmq/rabbitmq-server.git
cd rabbitmq-server
git checkout cli-reset-offset
make run-broker PLUGINS="rabbitmq_stream"

Open another terminal tab and use stream-perf-test to perform some offset tracking:

cd /tmp
wget -O stream-perf-test.jar https://github.com/rabbitmq/rabbitmq-java-tools-binaries-dev/releases/download/v-stream-perf-test-latest/stream-perf-test-latest.jar
java -jar stream-perf-test.jar --rate 100 --store-every 10 --time 5

Open another terminal tab and list the tracking information for the stream:

cd /tmp/rabbitmq-server
sbin/rabbitmq-streams list_stream_tracking stream

The output should look like the following:

Listing tracking information for stream stream ...
┌────────┬──────────┬────────────────┐
│ type   │ name     │ tracking_value │
├────────┼──────────┼────────────────┤
│ offset │ stream-1 │ 548            │
└────────┴──────────┴────────────────┘

Reset the offset for the stream/reference couple:

sbin/rabbitmq-streams reset_offset --stream stream --reference stream-1

Expected output:

Resetting stored offset ...
OK

List the tracking again:

sbin/rabbitmq-streams list_stream_tracking stream

The stored offset for the stream/reference should be 0:

Listing tracking information for stream stream ...
┌────────┬──────────┬────────────────┐
│ type   │ name     │ tracking_value │
├────────┼──────────┼────────────────┤
│ offset │ stream-1 │ 0              │
└────────┴──────────┴────────────────┘

@acogoluegnes acogoluegnes marked this pull request as ready for review July 1, 2025 11:55
@Gsantomaggio
Copy link
Member

I can't validate the code.

I tested the functionality and it works.

One question:
✅ If the stream does not exist, the command result is:

sbin/rabbitmq-streams reset_offset --stream stream-doesnt-exist --reference stream-1
Resetting stored offset ...
Error:
The stream does not exist

🤔 If the stream exists but the reference does not:

sbin/rabbitmq-streams reset_offset --stream stream --reference stream-doesnt-exist
Resetting stored offset ...
OK

Should the command return that the reference does not exist?

@michaelklishin
Copy link
Collaborator

@acogoluegnes has the best functional QA instructions, as usual.

acogoluegnes and others added 2 commits July 1, 2025 17:46
A user can set the stored offset for a stream/reference couple to 0.
This way a consumer can keep the same name and re-attach to the
beginning of a stream.

References #14124
@acogoluegnes acogoluegnes merged commit 3e61580 into main Jul 1, 2025
283 checks passed
@acogoluegnes acogoluegnes deleted the cli-reset-offset branch July 1, 2025 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants