Skip to content

Commit 3b6b9c8

Browse files
neilalexanderwallyqs
authored andcommitted
Fix panic in isGroupLeaderless
Need to capture `rg.node` while the JetStream lock is held, otherwise stopping an asset could race and it could be set back to `nil`. Signed-off-by: Neil Twigg <[email protected]>
1 parent adf8913 commit 3b6b9c8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

server/jetstream_cluster.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -940,20 +940,21 @@ func (js *jetStream) isGroupLeaderless(rg *raftGroup) bool {
940940
js.mu.RUnlock()
941941
return false
942942
}
943+
node := rg.node
943944
js.mu.RUnlock()
944945
// If we don't have a leader.
945-
if rg.node.GroupLeader() == _EMPTY_ {
946+
if node.GroupLeader() == _EMPTY_ {
946947
// Threshold for jetstream startup.
947948
const startupThreshold = 10 * time.Second
948949

949-
if rg.node.HadPreviousLeader() {
950+
if node.HadPreviousLeader() {
950951
// Make sure we have been running long enough to intelligently determine this.
951952
if time.Since(started) > startupThreshold {
952953
return true
953954
}
954955
}
955956
// Make sure we have been running for enough time.
956-
if time.Since(rg.node.Created()) > lostQuorumIntervalDefault {
957+
if time.Since(node.Created()) > lostQuorumIntervalDefault {
957958
return true
958959
}
959960
}

0 commit comments

Comments
 (0)