From 747d475e760883b69f63d74206b0b363446da877 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 7 Feb 2023 12:46:47 -0800 Subject: [PATCH] initialize subsystems that are not dependent on buckets first (#16559) --- cmd/server-main.go | 73 +++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/cmd/server-main.go b/cmd/server-main.go index c109c4ef2..feb9f4d70 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -668,50 +668,35 @@ func serverMain(ctx *cli.Context) { // Background all other operations such as initializing bucket metadata etc. go func() { - // Initialize transition tier configuration manager + // Initialize data scanner. + initDataScanner(GlobalContext, newObject) + + // Initialize background replication initBackgroundReplication(GlobalContext, newObject) + + // Initialize background transition initBackgroundTransition(GlobalContext, newObject) + // Initialize batch job pool. globalBatchJobPool = newBatchJobPool(GlobalContext, newObject, 100) + // Initialize the license update job + initLicenseUpdateJob(GlobalContext, newObject) + go func() { + // Initialize transition tier configuration manager err := globalTierConfigMgr.Init(GlobalContext, newObject) if err != nil { logger.LogIf(GlobalContext, err) - } - - globalTierJournal, err = initTierDeletionJournal(GlobalContext) - if err != nil { - logger.FatalIf(err, "Unable to initialize remote tier pending deletes journal") + } else { + globalTierJournal, err = initTierDeletionJournal(GlobalContext) + if err != nil { + logger.FatalIf(err, "Unable to initialize remote tier pending deletes journal") + } } }() - // Initialize quota manager. - globalBucketQuotaSys.Init(newObject) - - initDataScanner(GlobalContext, newObject) - - // List buckets to heal, and be re-used for loading configs. - buckets, err := newObject.ListBuckets(GlobalContext, BucketOptions{}) - if err != nil { - logger.LogIf(GlobalContext, fmt.Errorf("Unable to list buckets to heal: %w", err)) - } - // initialize replication resync state. - go globalReplicationPool.initResync(GlobalContext, buckets, newObject) - - // Populate existing buckets to the etcd backend - if globalDNSConfig != nil { - // Background this operation. - go initFederatorBackend(buckets, newObject) - } - - // Initialize bucket metadata sub-system. - globalBucketMetadataSys.Init(GlobalContext, buckets, newObject) - - // Initialize site replication manager. - globalSiteReplicationSys.Init(GlobalContext, newObject) - - // Initialize bucket notification system + // Initialize bucket notification system first before loading bucket metadata. logger.LogIf(GlobalContext, globalEventNotifier.InitBucketTargets(GlobalContext, newObject)) // initialize the new disk cache objects. @@ -724,8 +709,28 @@ func serverMain(ctx *cli.Context) { setCacheObjectLayer(cacheAPI) } - // Initialize the license update job - initLicenseUpdateJob(GlobalContext, newObject) + // List buckets to heal, and be re-used for loading configs. + buckets, err := newObject.ListBuckets(GlobalContext, BucketOptions{}) + if err != nil { + logger.LogIf(GlobalContext, fmt.Errorf("Unable to list buckets to heal: %w", err)) + } + // initialize replication resync state. + go globalReplicationPool.initResync(GlobalContext, buckets, newObject) + + // Initialize bucket metadata sub-system. + globalBucketMetadataSys.Init(GlobalContext, buckets, newObject) + + // Initialize site replication manager after bucket metadat + globalSiteReplicationSys.Init(GlobalContext, newObject) + + // Initialize quota manager. + globalBucketQuotaSys.Init(newObject) + + // Populate existing buckets to the etcd backend + if globalDNSConfig != nil { + // Background this operation. + go initFederatorBackend(buckets, newObject) + } // Prints the formatted startup message, if err is not nil then it prints additional information as well. printStartupMessage(getAPIEndpoints(), err)