Fix for a peer-remove of an R1 that would brick the stream.

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2023-08-22 17:45:19 -07:00
parent dc09bb764a
commit ddb7f9f9d5
2 changed files with 37 additions and 1 deletions

View File

@@ -5184,7 +5184,12 @@ func (cc *jetStreamCluster) remapStreamAssignment(sa *streamAssignment, removePe
return true
}
// If we are here let's remove the peer at least.
// If R1 just return to avoid bricking the stream.
if sa.Group.node == nil || len(sa.Group.Peers) == 1 {
return false
}
// If we are here let's remove the peer at least, as long as we are R>1
for i, peer := range sa.Group.Peers {
if peer == removePeer {
sa.Group.Peers[i] = sa.Group.Peers[len(sa.Group.Peers)-1]