Skip to content
Open
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
11 changes: 10 additions & 1 deletion bundle/direct/dstate/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,16 @@ func (db *DeploymentState) unlockedOpen(ctx context.Context, path string, withRe
StateVersion: currentStateVersion,
CLIVersion: build.GetInfo().Version,
}
return appendJSONLine(db.walFile, walHead)
if err := appendJSONLine(db.walFile, walHead); err != nil {
// Remove the WAL created just above: O_EXCL means it is ours, and
// without a header it carries nothing to recover. Leaving it makes
// every later open fail, with recovery on the header parse and
// without it on the unexpected WAL file.
db.walFile.Close()
db.walFile = nil
os.Remove(walPath)
return fmt.Errorf("failed to write WAL header to %s: %w", walPath, err)
}
}

return nil
Expand Down
Loading