Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fresh shard state in offline node repair #8

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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