Skip to content

fix: prevent dolt journal corruption from concurrent server starts#2504

Merged
steveyegge merged 1 commit intomainfrom
fix/dolt-journal-corruption-2430
Mar 12, 2026
Merged

fix: prevent dolt journal corruption from concurrent server starts#2504
steveyegge merged 1 commit intomainfrom
fix/dolt-journal-corruption-2430

Conversation

@steveyegge
Copy link
Copy Markdown
Collaborator

Summary

  • Fixes a race condition where KillStaleServers() ran outside the flock in EnsureRunning(), allowing one bd process to kill a server that another process was actively starting (PID file not yet written)
  • Moves KillStaleServers() inside Start() after the exclusive flock is acquired, making orphan cleanup and server start atomic
  • Root cause of journal corruption reported in GH#2430: concurrent dolt sql-server instances writing to the same journal file

Test plan

  • go build ./internal/doltserver/ compiles
  • go test ./internal/doltserver/ passes
  • Verify with concurrent bd commands that only one server starts (manual test with multiple terminals)

Fixes #2430

🤖 Generated with Claude Code

… (GH#2430)

KillStaleServers was called outside the exclusive file lock in
EnsureRunning(), creating a race where one process could kill a server
that another process was in the middle of starting (PID file not yet
written). This caused concurrent dolt sql-server instances to corrupt
the journal file.

Moving the cleanup inside Start() after the flock is acquired ensures
the kill-and-start sequence is atomic — no other process can interfere
between orphan cleanup and PID file creation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@steveyegge steveyegge merged commit 9e9b19f into main Mar 12, 2026
7 of 8 checks passed
@steveyegge steveyegge deleted the fix/dolt-journal-corruption-2430 branch March 12, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dolt journal corruption

1 participant