Skip to content

Commit

Permalink
find and fix error
Browse files Browse the repository at this point in the history
Signed-off-by: Fedor Partanskiy <pfi79@mail.ru>
  • Loading branch information
pfi79 committed Jan 8, 2024
1 parent 16856f9 commit e18f9b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion integration/raft/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
17 changes: 13 additions & 4 deletions orderer/common/multichannel/registrar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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()
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit e18f9b6

Please sign in to comment.