mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Merge pull request #3470 from goku321/random-consumer-peer
Fix peer randomisation when creating consumers groups for replica=1
This commit is contained in:
@@ -5950,8 +5950,9 @@ func (cc *jetStreamCluster) createGroupForConsumer(cfg *ConsumerConfig, sa *stre
|
||||
return nil
|
||||
}
|
||||
if cfg.Replicas > 0 && cfg.Replicas != len(peers) {
|
||||
peers = peers[:cfg.Replicas]
|
||||
// First shuffle the peers and then select to account for replica = 1.
|
||||
rand.Shuffle(len(peers), func(i, j int) { peers[i], peers[j] = peers[j], peers[i] })
|
||||
peers = peers[:cfg.Replicas]
|
||||
}
|
||||
storage := sa.Config.Storage
|
||||
if cfg.MemoryStorage {
|
||||
|
||||
Reference in New Issue
Block a user