Skip to content

Commit

Permalink
Let primary to be available for write earlier if data loss is allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
secwall committed Sep 9, 2024
1 parent 386e5b8 commit 704fc05
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/app/switchover.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,17 @@ func (app *App) performSwitchover(shardState map[string]*HostState, activeNodes
app.waitPoisonPill(app.config.Redis.WaitPoisonPillTimeout)
}

if len(aliveActiveNodes) == 1 || app.config.Redis.AllowDataLoss || app.config.Redis.MaxReplicasToWrite == 0 {
node := app.shard.Get(newMaster)
err, errConf := node.SetMinReplicas(app.ctx, 0)
if err != nil {
return fmt.Errorf("unable to set %s available for write before promote: %s", newMaster, err.Error())
}
if errConf != nil {
return fmt.Errorf("unable to rewrite config on %s before promote: %s", newMaster, errConf.Error())
}
}

if app.config.Redis.TurnBeforeSwitchover {
var psyncNodes []string
for _, host := range aliveActiveNodes {
Expand Down

0 comments on commit 704fc05

Please sign in to comment.