Skip to content

fix: prevent testdb_* accumulation in production .dolt-data#2184

Closed
DreadPirateRobertz wants to merge 2 commits intogastownhall:mainfrom
DreadPirateRobertz:polecat/fix-testdb-cleanup
Closed

fix: prevent testdb_* accumulation in production .dolt-data#2184
DreadPirateRobertz wants to merge 2 commits intogastownhall:mainfrom
DreadPirateRobertz:polecat/fix-testdb-cleanup

Conversation

@DreadPirateRobertz
Copy link
Copy Markdown
Contributor

Fixes gt-l98j

Root cause: gastown's test infrastructure blindly reuses GT_DOLT_PORT
when set, including the production port 3307. beads SDK v0.56.1 (used
by gastown) lacks the production port firewall that newer beads has,
so tests connecting to port 3307 create testdb_* databases directly
on the production Dolt server.

Two-layer fix:
1. Port guard: startDoltServer() now skips GT_DOLT_PORT=3307 and
   always starts an isolated ephemeral server for tests.
2. Defense-in-depth: cleanProductionTestDBs() runs at test startup
   to remove any already-leaked testdb_*/beads_t*/doctest_* dirs
   from ~/gt/.dolt-data/.

Fixes: gt-l98j

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added the status/needs-triage Inbox — we haven't looked at it yet label Feb 28, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 28, 2026

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
7663 1 7662 35
View the top 1 failed test(s) by shortest run time
github.com/steveyegge/gastown/internal/tmux::TestNewSessionWithCommand_ExecEnvBadBinary
Stack Traces | 0.09s run time
=== RUN   TestNewSessionWithCommand_ExecEnvBadBinary
    session_creation_test.go:52: NewSessionWithCommand should return error for exec env with missing binary
--- FAIL: TestNewSessionWithCommand_ExecEnvBadBinary (0.09s)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Old bd init naming convention created databases with beads_<prefix>
format. After migration to <rigname> convention, orphans like
beads_gastown, beads_gt, etc. persisted in .dolt-data/ indefinitely.

Adds targeted cleanup during EnsureRunning() that uses the existing
FindOrphanedDatabases() to detect beads_* databases not referenced
by any workspace's metadata.json, then removes them before the
server starts serving them.

Fixes: gt-7d4f

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@steveyegge
Copy link
Copy Markdown
Collaborator

This PR has a merge conflict after recent merges on main. Could you rebase onto main? The change itself looks good — just needs a clean merge.

@steveyegge
Copy link
Copy Markdown
Collaborator

The testutil infrastructure was significantly restructured on main (doltserver_unix.go was deleted and content merged elsewhere). This PR needs a non-trivial rebase to port the port-guard and cleanProductionTestDBs logic into the new file structure. The changes themselves are valuable — just need to be applied to the new layout.

steveyegge added a commit that referenced this pull request Mar 1, 2026
Auto-remove orphaned beads_* databases on Dolt server startup and replace
Docker-based test containers with a local dolt sql-server using file locks
for cross-process coordination.

PR: #2184
Co-authored-by: Chris Deal <DreadPirateRobertz@users.noreply.github.com>
@steveyegge
Copy link
Copy Markdown
Collaborator

Merged via fix-merge with conflict resolution

@steveyegge steveyegge closed this Mar 1, 2026
@DreadPirateRobertz DreadPirateRobertz deleted the polecat/fix-testdb-cleanup branch March 4, 2026 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/needs-triage Inbox — we haven't looked at it yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants