Repository navigation
Clear opt_start_time when an ordered consumer resumes by sequence - #1117
Open
ajaykr0905 wants to merge 2 commits into
Open
ajaykr0905 wants to merge 2 commits into
ajaykr0905 wants to merge 2 commits into
Conversation
An ordered consumer created with DeliverPolicy.BY_START_TIME never
recovered from a reset. reset_ordered_consumer switched the request to
BY_START_SEQUENCE but kept opt_start_time, so the server rejected the
re-create with err_code 10094 ("consumer delivery policy is deliver by
start sequence, but optional start time is also set"). The error only
reached error_cb, and the subscription stopped receiving messages.
Clear opt_start_time when resuming by sequence, as the nats-jetstream
ordered consumer already does.
Fixes nats-io#1094
This branch has not been deployed
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.
Fixes #1094.
An ordered consumer created with
DeliverPolicy.BY_START_TIMEstops receiving messages after its first reset.reset_ordered_consumerswitches the consumer request toBY_START_SEQUENCEand setsopt_start_seq, but it keepsopt_start_time. The server then rejects the re-create with400 err_code=10094("consumer delivery policy is deliver by start sequence, but optional start time is also set"). That error only goes toerror_cb, so the subscription stays open but never gets another message.This change clears
opt_start_timewhenever the reset resumes by sequence.ConsumerConfig.as_dict()skipsNonefields, so the re-create request no longer carries a start time. Thenats-jetstreamordered consumer already does the same when it resumes from a sequence, and so doesresetOrderedConsumerin nats.go.Tests:
OrderedConsumerTest.test_ordered_consumer_by_start_time_resumes_after_resetfollows the steps in the issue against a real server. It subscribes by start time, reads three messages, deletes the consumer to force a reset, publishes two more, and checks thatmsg-4andmsg-5arrive in order and that no JetStream API error reachederror_cb.OrderedConsumerResetUnitTest.test_reset_by_start_sequence_clears_start_timecallsreset_ordered_consumerwithout a server and checks the new request:BY_START_SEQUENCE, the next sequence, and noopt_start_time.Both tests fail on main. The real-server test times out, and
error_cbgets the 10094 error on every reset attempt. With the fix both pass, and the real-server test passed 35 runs in a row (25 on Python 3.13, 10 on 3.8).What I ran on macOS arm64, with nats-server v2.15.3 built by
go install github.com/nats-io/nats-server/v2@latestas in CI, in venvs set up like the CI job:-k ordered(the 6 existing ordered consumer tests and the 2 new ones) on Python 3.9.25, 3.10.22, 3.11.18 and 3.12.16: 8 passed on each.ruff format --check,ruff checkandcodespellpassed.ty check nats-core nats-serverpassed with four existing warnings in nats-core files; the legacynats/package is outside its scope.uv build --package nats-pysucceeded.I did not run the full legacy suite on 3.9 to 3.12, the Ubuntu or Windows runners, or the nats-core, nats-jetstream, nats-key-value and nats-server suites, since this only changes the legacy client.
#1099 (for #1087) edits the same lines: it keeps the initial policy until the first message arrives and leaves the resume-by-sequence path as it is. With this change alone, a consumer started by time that resets before its first message restarts from sequence 1, which is what the other delivery policies already do; #1099 covers that case. The two changes fit together; whichever lands second only needs this line moved inside the
if self._sseq != 0:branch. #1099's description points to #1095 for clearingopt_start_time, but that PR is no longer available.