Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions server/jetstream_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,8 @@ func (js *jetStream) monitorCluster() {
doSnapshot()
return
case <-rqch:
// Clean signal from shutdown routine so do best effort attempt to snapshot meta layer.
doSnapshot()
return
case <-qch:
// Clean signal from shutdown routine so do best effort attempt to snapshot meta layer.
Expand Down
2 changes: 1 addition & 1 deletion server/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,7 @@ func (n *raft) run() {
n.apply.push(nil)

runner:
for s.isRunning() {
for {
switch n.State() {
case Follower:
n.runAsFollower()
Expand Down
29 changes: 29 additions & 0 deletions server/raft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2773,6 +2773,35 @@ func TestNRGSnapshotRecovery(t *testing.T) {
require_Equal(t, n.applied, 0)
}

func TestNRGKeepRunningOnServerShutdown(t *testing.T) {
n, cleanup := initSingleMemRaftNode(t)
defer cleanup()

n.RLock()
s := n.s
wal := n.wal.(*memStore)
n.RUnlock()

n.wg.Add(1)
s.startGoRoutine(n.run, nil)

s.running.Store(false)
time.Sleep(time.Second)

wal.mu.RLock()
msgs := wal.msgs
wal.mu.RUnlock()
require_NotNil(t, msgs)

n.Stop()
n.WaitForStop()

wal.mu.RLock()
msgs = wal.msgs
wal.mu.RUnlock()
require_True(t, msgs == nil)
}

// This is a RaftChainOfBlocks test where a block is proposed and then we wait for all replicas to apply it before
// proposing the next one.
// The test may fail if:
Expand Down