Skip to content

Commit

Permalink
Merge pull request #1529 from hyperledger/retry_ns_fix
Browse files Browse the repository at this point in the history
fix: do not start multiple blockchain plugin on retry of namespace start
  • Loading branch information
EnriqueL8 authored Jun 20, 2024
2 parents ea06df6 + ca7fae9 commit 8fdaeb3
Showing 1 changed file with 34 additions and 28 deletions.
62 changes: 34 additions & 28 deletions internal/orchestrator/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,33 +191,34 @@ type Config struct {
}

type orchestrator struct {
ctx context.Context
cancelCtx context.CancelFunc
started bool
startedLock sync.Mutex
namespace *core.Namespace
config Config
plugins *Plugins
multiparty multiparty.Manager // only for multiparty
batch batch.Manager // only for multiparty
broadcast broadcast.Manager // only for multiparty
messaging privatemessaging.Manager // only for multiparty
sharedDownload shareddownload.Manager // only for multiparty
identity identity.Manager
events events.EventManager
networkmap networkmap.Manager
defhandler definitions.Handler
defsender definitions.Sender
data data.Manager
syncasync syncasync.Bridge
assets assets.Manager
bc boundCallbacks
contracts contracts.Manager
metrics metrics.Manager
cacheManager cache.Manager
operations operations.Manager
txHelper txcommon.Helper
txWriter txwriter.Writer
ctx context.Context
cancelCtx context.CancelFunc
started bool
startedBlockchainPlugin bool
startedLock sync.Mutex
namespace *core.Namespace
config Config
plugins *Plugins
multiparty multiparty.Manager // only for multiparty
batch batch.Manager // only for multiparty
broadcast broadcast.Manager // only for multiparty
messaging privatemessaging.Manager // only for multiparty
sharedDownload shareddownload.Manager // only for multiparty
identity identity.Manager
events events.EventManager
networkmap networkmap.Manager
defhandler definitions.Handler
defsender definitions.Sender
data data.Manager
syncasync syncasync.Bridge
assets assets.Manager
bc boundCallbacks
contracts contracts.Manager
metrics metrics.Manager
cacheManager cache.Manager
operations operations.Manager
txHelper txcommon.Helper
txWriter txwriter.Writer
}

func NewOrchestrator(ns *core.Namespace, config Config, plugins *Plugins, metrics metrics.Manager, cacheManager cache.Manager) Orchestrator {
Expand Down Expand Up @@ -568,11 +569,16 @@ func (or *orchestrator) initManagers(ctx context.Context) (err error) {
}

func (or *orchestrator) initComponents(ctx context.Context) (err error) {
if or.blockchain() != nil {
// The blockchain plugin doesn't return a manager or struct that we can check for
// nil like all the other mangagers to see if it has been initialised before!
// So we have a boolean to check so that when the retry wrapper initialises these components
// again we do have multiple ones running
if or.blockchain() != nil && !or.startedBlockchainPlugin {
err = or.blockchain().StartNamespace(ctx, or.namespace.Name)
if err != nil {
return err
}
or.startedBlockchainPlugin = true
}

if or.data == nil {
Expand Down

0 comments on commit 8fdaeb3

Please sign in to comment.