Skip to content

Commit

Permalink
Use fresh shard state in offline node repair
Browse files Browse the repository at this point in the history
  • Loading branch information
secwall committed Jan 8, 2024
1 parent b3001c6 commit c912f52
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/app/candidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (app *App) stateCandidate() appState {
app.logger.Error("Candidate: failed to get current master from DCS", "error", err)
return stateCandidate
}
app.repairLocalNode(shardState, master)
app.repairLocalNode(master)

if app.dcs.AcquireLock(pathManagerLock) {
return stateManager
Expand Down
2 changes: 1 addition & 1 deletion internal/app/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (app *App) stateManager() appState {
return stateMaintenance
}

app.repairLocalNode(shardState, master)
app.repairLocalNode(master)

var switchover Switchover
if err := app.dcs.Get(pathCurrentSwitch, &switchover); err == nil {
Expand Down
7 changes: 6 additions & 1 deletion internal/app/repair.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (app *App) repairReplica(node *redis.Node, masterState, state *HostState, m
}
}

func (app *App) repairLocalNode(shardState map[string]*HostState, master string) {
func (app *App) repairLocalNode(master string) {
local := app.shard.Local()

offline, err := local.IsOffline(app.ctx)
Expand All @@ -132,6 +132,11 @@ func (app *App) repairLocalNode(shardState map[string]*HostState, master string)
return
}

shardState, err := app.getShardStateFromDB()
if err != nil {
app.logger.Error("Local repair: unable to get actual shard state", "error", err)
return
}
state, ok := shardState[local.FQDN()]
if !ok {
app.logger.Error("Local repair: unable to find local node in shard state")
Expand Down

0 comments on commit c912f52

Please sign in to comment.