Skip to content

Commit

Permalink
[FIXED] Freeze n.Applied for consumer when shutting down (#6133)
Browse files Browse the repository at this point in the history
Similar to #6087, but for
consumers. During shutdown we can't guarantee we'll still flush all that
is needed. So don't touch `n.Applied` and rely on replay so those
changes can be properly persisted.

Signed-off-by: Maurice van Veen <[email protected]>
  • Loading branch information
derekcollison authored Nov 14, 2024
2 parents b324c5f + f07c091 commit 40b3042
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/jetstream_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -4949,7 +4949,11 @@ func (js *jetStream) monitorConsumer(o *consumer, ca *consumerAssignment) {
doSnapshot(true)
}
} else if err := js.applyConsumerEntries(o, ce, isLeader); err == nil {
ne, nb := n.Applied(ce.Index)
var ne, nb uint64
// We can't guarantee writes are flushed while we're shutting down. Just rely on replay during recovery.
if !js.isShuttingDown() {
ne, nb = n.Applied(ce.Index)
}
ce.ReturnToPool()
// If we have at least min entries to compact, go ahead and snapshot/compact.
if nb > 0 && ne >= compactNumMin || nb > compactSizeMin {
Expand Down

0 comments on commit 40b3042

Please sign in to comment.