Skip to content

Commit

Permalink
[dbnode] Add ability to force enable cold writes from config (#3002)
Browse files Browse the repository at this point in the history
  • Loading branch information
robskillington committed Nov 3, 2020
1 parent 59c34aa commit d05746f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/cmd/services/m3dbnode/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/cmd/services/m3dbnode/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ func TestConfiguration(t *testing.T) {
maxOutstandingRepairedBytes: 0
maxEncodersPerBlock: 0
tchannel: null
forceColdWritesEnabled: null
coordinator: null
`

Expand Down
10 changes: 8 additions & 2 deletions src/dbnode/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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))
Expand All @@ -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))
Expand Down

0 comments on commit d05746f

Please sign in to comment.