Skip to content
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

[FIXED] Consumer stuck/slowdown during leader changes or redeliveries #6387

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

MauriceVanVeen
Copy link
Member

Contains two fixes:

  1. If a message is Acked, o.awl is incremented and the message is pushed into o.ackMsgs. However, if the consumer leader steps down (with o.setLeader(false)), o.ackMsgs.drain() is called, but o.awl is not reset. This results in a stuck consumer that can't redeliver messages due to o.checkPending short-circuiting on o.awl being set.
  2. If a message is scheduled for redelivery but a race condition is hit where the message has been removed in the meantime. We would not catch this, keep the message around for redelivery, and as a result slowdown a lot. Instead the message should be removed since it can not be delivered anymore.

Resolves #6374

Signed-off-by: Maurice van Veen github@mauricevanveen.com

@MauriceVanVeen MauriceVanVeen requested a review from a team as a code owner January 21, 2025 08:43
Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
@MauriceVanVeen MauriceVanVeen force-pushed the maurice/consumer-redelivery-stuck branch from 86dcd36 to 090fd64 Compare January 21, 2025 16:13
Copy link
Member

@neilalexander neilalexander left a comment

Choose a reason for hiding this comment

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

LGTM

@derekcollison derekcollison merged commit 4be933f into main Jan 22, 2025
5 checks passed
@derekcollison derekcollison deleted the maurice/consumer-redelivery-stuck branch January 22, 2025 13:19
neilalexander added a commit that referenced this pull request Jan 22, 2025
Includes the following:

- #6373
- #6377
- #6379
- #6390
- #6392
- #6387
- #6292

Signed-off-by: Neil Twigg <neil@nats.io>
derekcollison added a commit that referenced this pull request Jan 23, 2025
#6399)

Follow-up of #6387

Deleting from `o.pending` and `o.rdc` in `o.getNextMsg` was a
correctness issue. Due to us calling `go o.processTerm` we could go into
`o.getNextMsg` before `o.processTerm` has adjusted the accounting for
the message that's deleted. So we must not change `o.pending/o.rdc`
ourselves, and we can just skip, waiting for `o.processTerm` to run.

Resolves #6374

Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
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.

Stuck and inconsistent consumer when deleting non-acked messages
3 participants