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

Don't unconditionally send consumer snapshot when becoming leader #4965

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 0 additions & 10 deletions server/jetstream_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -4660,16 +4660,6 @@ func (js *jetStream) monitorConsumer(o *consumer, ca *consumerAssignment) {
js.setConsumerAssignmentRecovering(ca)
}

// Synchronize everyone to our state.
Copy link
Member

Choose a reason for hiding this comment

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

Should we remove all together or adjust to make sure our upper state is correct?

It is there for a reason :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you remember what that reason was? I can't find anything written down as to why, the best I can find is from the commit message in cc77d66 which says:

Also sync other consumers when taking over as leader but no need to process snapshots when we are in fact the leader.

As far as I can tell everything should work without this because the Raft machinery would be keeping the ConsumerStore up-to-date on the replicas in the usual way anyway, whereas sending snapshots from the upper layer directly opens up a potential for a race between the committed Raft node state and the applied upper layer state, but I'm not sure if I'm missing something here.

Copy link
Member

Choose a reason for hiding this comment

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

We were experiencing state skew, and I wanted us synched. But could have been from a prior bug that has since been corrected.

if isLeader && n != nil {
// Only send out if we have state.
if _, _, applied := n.Progress(); applied > 0 {
if snap, err := o.store.EncodedState(); err == nil {
n.SendSnapshot(snap)
}
}
}

// Process the change.
if err := js.processConsumerLeaderChange(o, isLeader); err == nil && isLeader {
doSnapshot(true)
Expand Down