Skip to content

Ignore a deferred un-assign superseded by a later rebalance - #2818

Draft
delthas wants to merge 1 commit into
development/9.5from
improvement/BB-835/rebalance-guard
Draft

Ignore a deferred un-assign superseded by a later rebalance#2818
delthas wants to merge 1 commit into
development/9.5from
improvement/BB-835/rebalance-guard

Conversation

@delthas

@delthas delthas commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

On ERR__REVOKE_PARTITIONS the un-assign is deferred until in-flight work has drained, so offsets can be committed before the partitions are released. If the next rebalance grants those partitions back before the drain finishes, the deferred callback still fires and un-assigns them.

sequenceDiagram
    participant K as Kafka
    participant C as BackbeatConsumer
    K->>C: revoke [0-4]
    Note right of C: work in flight,<br/>un-assign deferred
    K->>C: assign [0-4]
    C->>C: assign() applied
    Note right of C: drain completes
    C->>K: unassign() — discards the new assignment
    Note right of C: owns partitions at the broker,<br/>no local assignment, no rebalance to recover
Loading

Membership has not changed, so nothing triggers another rebalance and the consumer is stuck until restarted, while looking healthy on every liveness signal. Observed in a CTST census run: idle for 2 h 35 min with 188 of 199 messages stranded.

Changes

  • _rebalanceId, bumped on every rebalance event. A deferred un-assign gives up when its id no longer matches — checked before touching the drain signals and watchdog, which by then belong to a later rebalance, and again before unassign(), since publishing offsets to zookeeper in between is asynchronous and leaves a second window.
  • The drain watchdog is now cleared on every rebalance, not only on assignment. A revoke following another revoke used to orphan the first timer, which would later disconnect a consumer that was not stuck.
  • New SUPERSEDED value on the existing rebalance counter, so the race is visible in metrics. Nothing downstream enumerates these values.

Tests

Seven unit tests in tests/unit/backbeatConsumer.js, no broker needed (existing BackbeatConsumerMock). Each guard was verified by reverting it and confirming exactly one test fails.

Note

A superseded cycle does not emit 'unassign', so a shutdown racing an assignment still leaves close() waiting. That is pre-existing and owned by BB-833: emitting the event without having un-assigned would push close() into disconnect() while still holding partitions, which hangs.

Issue: BB-835

@bert-e

bert-e commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Hello delthas,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Available options
name description privileged authored
/after_pull_request Wait for the given pull request id to be merged before continuing with the current one.
/bypass_author_approval Bypass the pull request author's approval
/bypass_build_status Bypass the build and test status
/bypass_commit_size Bypass the check on the size of the changeset TBA
/bypass_incompatible_branch Bypass the check on the source branch prefix
/bypass_jira_check Bypass the Jira issue check
/bypass_peer_approval Bypass the pull request peers' approval
/bypass_leader_approval Bypass the pull request leaders' approval
/approve Instruct Bert-E that the author has approved the pull request. ✍️
/create_pull_requests Allow the creation of integration pull requests.
/create_integration_branches Allow the creation of integration branches.
/no_octopus Prevent Wall-E from doing any octopus merge and use multiple consecutive merge instead
/unanimity Change review acceptance criteria from one reviewer at least to all reviewers
/wait Instruct Bert-E not to run until further notice.
Available commands
name description privileged
/help Print Bert-E's manual in the pull request.
/status Print Bert-E's current status in the pull request.
/clear Remove all comments from Bert-E from the history TBA
/retry Re-start a fresh build TBA
/build Re-start a fresh build TBA
/force_reset Delete integration branches & pull requests, and restart merge process from the beginning.
/reset Try to remove integration branches unless there are commits on them which do not appear on the source branch.

Status report is not available.

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.59%. Comparing base (52b9510) to head (fa04a32).
⚠️ Report is 1 commits behind head on development/9.5.

Additional details and impacted files

Impacted file tree graph

Files with missing lines Coverage Δ
lib/BackbeatConsumer.js 94.84% <100.00%> (-0.06%) ⬇️
lib/constants.js 100.00% <ø> (ø)

... and 3 files with indirect coverage changes

Components Coverage Δ
Bucket Notification 80.27% <ø> (ø)
Core Library 81.49% <100.00%> (-0.45%) ⬇️
Ingestion 70.09% <ø> (ø)
Lifecycle 80.46% <ø> (ø)
Oplog Populator 85.83% <ø> (ø)
Replication 62.04% <ø> (+0.03%) ⬆️
Bucket Scanner 85.76% <ø> (ø)
@@                 Coverage Diff                 @@
##           development/9.5    #2818      +/-   ##
===================================================
- Coverage            75.76%   75.59%   -0.17%     
===================================================
  Files                  200      200              
  Lines                13922    13937      +15     
===================================================
- Hits                 10548    10536      -12     
- Misses                3364     3391      +27     
  Partials                10       10              
Flag Coverage Δ
api:retry 9.09% <0.00%> (-0.02%) ⬇️
api:routes 8.86% <0.00%> (-0.01%) ⬇️
bucket-scanner 85.76% <ø> (ø)
ft_test:queuepopulator 10.14% <6.66%> (-0.85%) ⬇️
ingestion 12.25% <0.00%> (-0.02%) ⬇️
lib 8.87% <60.00%> (+0.04%) ⬆️
lifecycle 19.36% <60.00%> (+0.05%) ⬆️
notification 1.01% <0.00%> (-0.01%) ⬇️
oplogPopulator 0.13% <0.00%> (-0.01%) ⬇️
replication 18.89% <60.00%> (+0.04%) ⬆️
unit 55.18% <100.00%> (+0.29%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@scality scality deleted a comment from bert-e Aug 19, 2026
@bert-e

bert-e commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

On ERR__REVOKE_PARTITIONS the un-assign is deferred until the processing
queue and the offset ledger have drained. If the next rebalance granted
the partitions back before that happened, the deferred callback still
ran and un-assigned them: the consumer then owned partitions at the
broker with no local assignment, and since group membership had not
changed, nothing triggered another rebalance to rescue it.

Track a rebalance id, bumped on every rebalance event, and give up on a
deferred un-assign whose id no longer matches. The check runs again
before un-assigning, as publishing offsets to zookeeper in between is
asynchronous and leaves a second window for the partitions to come back.

The drain watchdog is now cleared on every rebalance rather than only on
assignment, so a timer armed by a superseded revoke can no longer
disconnect a consumer that is not stuck.

Issue: BB-835
@delthas
delthas force-pushed the improvement/BB-835/rebalance-guard branch from de184b1 to fa04a32 Compare August 19, 2026 17:47
@scality scality deleted a comment from bert-e Aug 19, 2026
@bert-e

bert-e commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Request integration branches

Waiting for integration branch creation to be requested by the user.

To request integration branches, please comment on this pull request with the following command:

/create_integration_branches

Alternatively, the /approve and /create_pull_requests commands will automatically
create the integration branches.

@scality scality deleted a comment from bert-e Aug 19, 2026
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