diff --git a/integration/raft/config_test.go b/integration/raft/config_test.go index fe66e4459a7..fe1ab7dd6a4 100644 --- a/integration/raft/config_test.go +++ b/integration/raft/config_test.go @@ -1261,7 +1261,7 @@ var _ = Describe("EndToEnd reconfiguration and onboarding", func() { o2 := network.Orderer("orderer2") o3 := network.Orderer("orderer3") - By("Waiting for them to elect a leader") + By("Waiting for them to select a leader") FindLeader(ordererRunners) assertBlockReception(map[string]int{ diff --git a/orderer/common/multichannel/registrar.go b/orderer/common/multichannel/registrar.go index 61f10d44236..937633f2a22 100644 --- a/orderer/common/multichannel/registrar.go +++ b/orderer/common/multichannel/registrar.go @@ -47,9 +47,10 @@ var logger = flogging.MustGetLogger("orderer.common.multichannel") type Registrar struct { config localconfig.TopLevel - lock sync.RWMutex - chains map[string]*ChainSupport - followers map[string]*follower.Chain + lock sync.RWMutex + removeChLock sync.RWMutex + chains map[string]*ChainSupport + followers map[string]*follower.Chain // existence indicates removal is in-progress or failed // when failed, the status will indicate failed all other states // denote an in-progress removal @@ -489,6 +490,11 @@ func (r *Registrar) createNewChain(configtx *cb.Envelope) *ChainSupport { // It is called when a follower detects a config block that indicates cluster membership and halts, transferring // execution to the consensus.Chain. func (r *Registrar) SwitchFollowerToChain(channelID string) { + if !r.removeChLock.TryLock() { + return + } + defer r.removeChLock.Unlock() + r.lock.Lock() defer r.lock.Unlock() @@ -504,7 +510,7 @@ func (r *Registrar) SwitchFollowerToChain(channelID string) { delete(r.followers, channelID) logger.Debugf("Removed follower for channel %s", channelID) cs := r.createNewChain(configTx(lf)) - if err := r.removeJoinBlock(channelID); err != nil { + if err = r.removeJoinBlock(channelID); err != nil { logger.Panicf("Failed removing join-block for channel: %s: %v", channelID, err) } cs.start() @@ -767,6 +773,9 @@ func (r *Registrar) createFollower( // RemoveChannel instructs the orderer to remove a channel. func (r *Registrar) RemoveChannel(channelID string) error { + r.removeChLock.Lock() + defer r.removeChLock.Unlock() + r.lock.Lock() defer r.lock.Unlock()