Skip to content

Commit

Permalink
Merge ed9709a into backport/gh-19720-empty-server-metadata/quickly-dy…
Browse files Browse the repository at this point in the history
…namic-bluebird
  • Loading branch information
hc-github-team-consul-core authored Jan 5, 2024
2 parents c397f2f + ed9709a commit 990bfbb
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -4626,12 +4626,15 @@ func (a *Agent) persistServerMetadata() {
continue
}

sf := f.(*safeio.File)
if err := sf.Commit(); err != nil {
a.logger.Error("failed to commit server metadata", "error", err)
continue
// Use safeio.File to ensure the file is written to disk atomically
if sf, ok := f.(*safeio.File); ok {
if err := sf.Commit(); err != nil {
sf.Close()
a.logger.Error("failed to commit server metadata", "error", err)
continue
}
}
sf.Close()
f.Close()
case <-a.shutdownCh:
return
}
Expand Down

0 comments on commit 990bfbb

Please sign in to comment.