Skip to content

[IMPROVED] Bypass meta-layer's API queue for non-existent consumers.#6176

Merged
derekcollison merged 2 commits intomainfrom
no-ca-bypass
Nov 26, 2024
Merged

[IMPROVED] Bypass meta-layer's API queue for non-existent consumers.#6176
derekcollison merged 2 commits intomainfrom
no-ca-bypass

Conversation

@derekcollison
Copy link
Copy Markdown
Member

Processing a missing consumer was a heavier operation on the meta-layer and could lead to API queue buildup.
This processes that condition at point of entry to the system vs at the meta-layer.
If the consumer assignment does exist we process as normal for now.

Also moved jetstream clustered state and system account to atomics to avoid lock contention.
Add in lookup for both stream and consumer assignments at the same time.

Signed-off-by: Derek Collison derek@nats.io

@derekcollison derekcollison requested a review from a team as a code owner November 25, 2024 23:56
Copy link
Copy Markdown
Member

@wallyqs wallyqs left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
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.

Otherwise LGTM!

Add in lookup for both stream and consumer assignments at the same time.

Signed-off-by: Derek Collison <derek@nats.io>
… or stream.

Processing a missing consumer was a heavier operation on the meta-layer and could lead to API queue buildup.
This processes that condition at point of entry to the system vs at the meta-layer. If the consumer assignment exists we do as normal for now.

Signed-off-by: Derek Collison <derek@nats.io>
@derekcollison derekcollison merged commit eba1953 into main Nov 26, 2024
@derekcollison derekcollison deleted the no-ca-bypass branch November 26, 2024 13:37
neilalexander added a commit that referenced this pull request Nov 26, 2024
Includes the following:

- #6169
- #6165
- #6173
- #6175
- #6176
- #6178

Signed-off-by: Neil Twigg <neil@nats.io>
MauriceVanVeen added a commit that referenced this pull request Dec 13, 2024
…sumers. (#6176)"

This reverts commit eba1953, reversing
changes made to fa50c75.
MauriceVanVeen added a commit that referenced this pull request Dec 13, 2024
Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
MauriceVanVeen added a commit that referenced this pull request Dec 13, 2024
…sumers. (#6176)"

This reverts commit eba1953, reversing
changes made to fa50c75.
MauriceVanVeen added a commit that referenced this pull request Dec 13, 2024
Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
derekcollison added a commit that referenced this pull request Dec 13, 2024
…after create (#6250)

Reverts #6176 and adds a test
that explicitly checks for a consumer info after create using
`PauseApply`. This simulates where there's agreement to create the
consumer but applies are paused, so short-circuiting for a consumer info
would result in a 404.

Normally it would depend on how quick the applies go through the queue,
but for the test just pausing and resuming applies is more reliable.

Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
neilalexander pushed a commit that referenced this pull request Dec 13, 2024
…sumers. (#6176)"

This reverts commit eba1953, reversing
changes made to fa50c75.
neilalexander pushed a commit that referenced this pull request Dec 13, 2024
Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
wallyqs pushed a commit to wallyqs/nats-server that referenced this pull request Mar 4, 2026
…posals

Change jsConsumerInfoRequest to use consumerAssignmentOrInflight() instead
of consumerAssignment() when looking up consumer assignments. This prevents
the meta leader from returning "consumer not found" (404) when a consumer
create proposal has been submitted to Raft but not yet applied.

This is the same root cause that led to the revert of nats-io#6176 in nats-io#6250:
when the meta leader processes an info request before a create proposal
is applied, consumerAssignment() returns nil and the meta leader
short-circuits with a 404. Using consumerAssignmentOrInflight() finds
the inflight proposal and allows the request to proceed through the
normal code path, returning partial info (config + defaults) instead.

The fix is safe for inflight deletes: consumerAssignmentOrInflight()
returns nil when the inflight entry has deleted=true, so info requests
for consumers being deleted still correctly return 404.

https://claude.ai/code/session_01Cv5a3WaLfJSU9vYsLHjUtD
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.

3 participants