Skip to content

[IMPROVED] NRG: Reliable peer current/lag state#7885

Merged
neilalexander merged 1 commit intomainfrom
maurice/reliable-peer-state
Mar 2, 2026
Merged

[IMPROVED] NRG: Reliable peer current/lag state#7885
neilalexander merged 1 commit intomainfrom
maurice/reliable-peer-state

Conversation

@MauriceVanVeen
Copy link
Copy Markdown
Member

Follow-up to #7402. Also resetting the last replicated index, since we only know it if we're the leader, since only the leader is in contact with all servers and knows the amount of messages they have persisted in their logs.

The Lag and Current values were mostly unusable/stale/incorrect when read on a follower node. These values are returned in requests like stream and consumer info, as well as JSZ. So, this PR makes the n.Peers() state more usable and consistent:

  • The Lag/Current fields now accurately describe whether the current server is current (or lags) when compared with the peer in the list.
  • Only the leader will report Lag. All followers that are part of quorum will report Current: true, Lag: 0. Other non-current followers not part of quorum will show Lag of the amount of entries that are committed but not yet persisted on this peer. (This was already the case)
  • A follower will always report other followers as not current with no lag. It doesn't have any contact with other peers, so this data is not useful either way. (Previously this contained stale/unused data making it incorrect and deceiving at worst).
  • A follower will report in Current whether it has seen the leader recently.

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

Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
@MauriceVanVeen MauriceVanVeen requested a review from a team as a code owner February 27, 2026 14:54
@sciascid
Copy link
Copy Markdown
Contributor

=== RUN   TestJetStreamLeafNodeClusterExtensionWithSystemAccount/true-true
    jetstream_leafnode_test.go:532: Expected a cluster peer count of 4, got 2

A regression? Or just flaky test?

@MauriceVanVeen
Copy link
Copy Markdown
Member Author

Or just flaky test?

Flaky

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.

LGTM

@neilalexander neilalexander merged commit 40a4f08 into main Mar 2, 2026
90 of 93 checks passed
@neilalexander neilalexander deleted the maurice/reliable-peer-state branch March 2, 2026 11:49
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.

4 participants