From d05746f922978e931b5c0e24a9b8c3205cc6cc72 Mon Sep 17 00:00:00 2001 From: Rob Skillington Date: Thu, 10 Dec 2020 20:13:25 -0500 Subject: [PATCH] [dbnode] Add ability to force enable cold writes from config (#3002) --- src/cmd/services/m3dbnode/config/config.go | 4 ++++ src/cmd/services/m3dbnode/config/config_test.go | 1 + src/dbnode/server/server.go | 10 ++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/config.go b/src/cmd/services/m3dbnode/config/config.go index 8933aa516c..5ece33f33e 100644 --- a/src/cmd/services/m3dbnode/config/config.go +++ b/src/cmd/services/m3dbnode/config/config.go @@ -160,6 +160,10 @@ type DBConfiguration struct { // TChannel exposes TChannel config options. TChannel *TChannelConfiguration `yaml:"tchannel"` + + // ForceColdWritesEnabled will force enable cold writes for all namespaces + // if set. + ForceColdWritesEnabled *bool `yaml:"forceColdWritesEnabled"` } // InitDefaultsAndValidate initializes all default values and validates the Configuration. diff --git a/src/cmd/services/m3dbnode/config/config_test.go b/src/cmd/services/m3dbnode/config/config_test.go index daadbc7d79..8df9fb18cc 100644 --- a/src/cmd/services/m3dbnode/config/config_test.go +++ b/src/cmd/services/m3dbnode/config/config_test.go @@ -728,6 +728,7 @@ func TestConfiguration(t *testing.T) { maxOutstandingRepairedBytes: 0 maxEncodersPerBlock: 0 tchannel: null + forceColdWritesEnabled: null coordinator: null ` diff --git a/src/dbnode/server/server.go b/src/dbnode/server/server.go index c944bcd05d..8550abd2ae 100644 --- a/src/dbnode/server/server.go +++ b/src/dbnode/server/server.go @@ -589,6 +589,12 @@ func Run(runOpts RunOptions) { } opts = opts.SetPersistManager(pm) + forceEnableColdWrites := runOpts.StorageOptions.ForceColdWritesEnabled + if value := cfg.ForceColdWritesEnabled; value != nil { + // Allow forcing cold writes to be enabled by config. + forceEnableColdWrites = *value + } + var ( envCfg environment.ConfigureResults ) @@ -599,7 +605,7 @@ func Run(runOpts RunOptions) { InstrumentOpts: iopts, HashingSeed: cfg.Hashing.Seed, NewDirectoryMode: newDirectoryMode, - ForceColdWritesEnabled: runOpts.StorageOptions.ForceColdWritesEnabled, + ForceColdWritesEnabled: forceEnableColdWrites, }) if err != nil { logger.Fatal("could not initialize dynamic config", zap.Error(err)) @@ -610,7 +616,7 @@ func Run(runOpts RunOptions) { envCfg, err = cfg.EnvironmentConfig.Configure(environment.ConfigurationParameters{ InstrumentOpts: iopts, HostID: hostID, - ForceColdWritesEnabled: runOpts.StorageOptions.ForceColdWritesEnabled, + ForceColdWritesEnabled: forceEnableColdWrites, }) if err != nil { logger.Fatal("could not initialize static config", zap.Error(err))