Skip to content

fix(sdk): stream should terminate after consumer shutdown - #3964

Merged
hubcio merged 2 commits into
apache:masterfrom
haubur:fix/polling-after-consumer-shutdown
Sep 1, 2026
Merged

fix(sdk): stream should terminate after consumer shutdown#3964
hubcio merged 2 commits into
apache:masterfrom
haubur:fix/polling-after-consumer-shutdown

Conversation

@haubur

@haubur haubur commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR address?

Closes #3910

Rationale

After consumer.shutdown() calling consumer.next() was still possible. Causing

  • for a standalone consumer to poll fresh from the server, while storing offsets was unreachable due to dropping the channel on shutdown()
  • for a consumer group to hang indefinitely while trying to build a new poll future

What changed?

When writing the issue I said that the preferred way would be to return an IggyError to allow user handling.
However, calling next() on a shut down consumer now returns: Poll::Ready(None) indicating a terminated stream as intended by the futures crate: https://docs.rs/futures/latest/futures/prelude/trait.Stream.html#:~:text=Poll%3A%3AReady%28None%29%20means%20that%20the%20stream%20has%20terminated%2C%20and%20poll%5Fnext%20should%20not%20be%20invoked%20again

Local Execution

  • Passed
  • Pre-commit hooks ran

@github-actions

Copy link
Copy Markdown

Thanks for the PR. It is labeled S-waiting-on-review and queued for review.

Slash commands (own line, regular comment) move it around the queue:

  • /ready - back to S-waiting-on-review after addressing feedback
  • /author - flip to S-waiting-on-author while you finish changes
  • /request-review @user-or-team - request a reviewer

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Aug 25, 2026
@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.18182% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.94%. Comparing base (bb97397) to head (71e99b7).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
core/sdk/src/clients/consumer.rs 93.18% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3964      +/-   ##
============================================
- Coverage     84.97%   84.94%   -0.04%     
  Complexity     1402     1402              
============================================
  Files          1225     1225              
  Lines        180182   180224      +42     
  Branches     146486   146528      +42     
============================================
- Hits         153107   153088      -19     
- Misses        23043    23061      +18     
- Partials       4032     4075      +43     
Components Coverage Δ
Rust Core 85.83% <93.18%> (-0.04%) ⬇️
Java SDK 67.29% <ø> (ø)
C# SDK 75.38% <ø> (+0.01%) ⬆️
Python SDK 90.06% <ø> (ø)
PHP SDK 85.65% <ø> (ø)
Node SDK 96.13% <ø> (-0.12%) ⬇️
Go SDK 69.35% <ø> (+0.03%) ⬆️
Files with missing lines Coverage Δ
core/sdk/src/clients/consumer.rs 76.22% <93.18%> (+4.41%) ⬆️

... and 35 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ethanlin01x ethanlin01x left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread core/sdk/src/clients/consumer.rs
@hubcio
hubcio merged commit b1b911f into apache:master Sep 1, 2026
97 checks passed
@github-actions github-actions Bot removed the S-waiting-on-review PR is waiting on a reviewer label Sep 1, 2026
hubcio added a commit to haubur/iggy that referenced this pull request Sep 1, 2026
The IggyConsumer rustdoc added on this branch promises behaviour
the SDK does not have, and three of those promises lose data when
followed. Any polling strategy but next() on a group member: the
consumer keeps one continuation cursor for all partitions, applies
it to whichever partition the next poll hits, and the default
auto-commit commits the skipped range. AutoCommit::Disabled with
shutdown(): the final flush commits the reading position under
every setting, so the message whose handler failed goes with it.
store_offset(0) as a rewind: next() resumes at stored + 1 and the
interval task re-commits the old position within a second.

Rewrite the affected sections against the code at this revision.
The stream yields None after shutdown() since apache#3964, AutoCommitAfter
fires at the partition head seen by the poll and also after Err, a
failed decrypt is a permanent skip under the default and a retry
loop otherwise, partition_id() reflects the last poll response
including empty ones, the offset getters seed Some(0), surplus
group members keep syncing instead of idling, and
do_not_auto_join_consumer_group() leaves a member unable to poll.
The examples match on the stream item instead of bailing out with
?, and the manual-commit example drops the inert allow_replay().

Restore the apache#3668 comments that explain why the commit tasks drain
before the group leave, cut comments that restate the next line,
and keep the auto-commit mechanics in one place, the type-level
doc, with init(), shutdown() and the Stream impl linking to it.

Doc and comment lines only. The code defects behind these
sentences are left for separate fixes.
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.

bug(Rust SDK): IggyConsumer::next() after shutdown() hangs or silently drops offsets

4 participants