fix(testutil): narrow to test-only per review — drop retry-classifier change, reword visibility-wait comments
bee-ghosttrack's review (2026-09-03) on #5788 flagged that the isRetryableError "database not found" case was a real production behaviour change riding along in a PR described as test infrastructure: it turns a genuinely-missing-database failure from immediate into a full ~30s backoff (serverRetryMaxElapsed) across six withRetryClassified call sites. Dropping it entirely — SetupSharedTestDB's own visibility poll in testdoltbranch.go already resolves the catalog race the classifier case was meant to backstop, so it was never load-bearing for this fix. Also rewords waitForDatabaseVisible's doc comment to describe what USE on a pooled connection actually proves — that one connection observed the catalog refresh, not a pool-wide guarantee, and that USE mutates that connection's session default database as a side effect — and notes as a comment (not a behaviour change) that the backoff cap can let delay reach ~1.6s before capping, which is harmless inside the 10s bound. testmain_test.go's teardown also unset BEADS_DOLT_SERVER_PORT, the other half of the same port-pin hunk the rebase already dropped in favour of main's ambient-port FATAL guard (#5837); that half merged cleanly instead of conflicting, so it survived silently until now. Removed — main never sets that var, so unsetting it was dead code. TestSetupSharedTestDB_NewStoreOpens and the rest of the visibility suite still pass without the classifier change (podman testcontainer run: 5 PASS / 0 FAIL / 0 SKIP). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
1472e7d85e
commit
eea022b6e8
3 changed files with 10 additions and 10 deletions
|
|
@ -698,16 +698,11 @@ func isRetryableError(err error) bool {
|
|||
}
|
||||
// Dolt server catalog race: after CREATE DATABASE, the server's in-memory
|
||||
// catalog may not have registered the new database yet. The immediately
|
||||
// following USE (implicit via DSN) fails with "Unknown database" (standard
|
||||
// MySQL wording) or "database not found: <name>" (Dolt's own wording from
|
||||
// go-mysql-server). Both are transient and resolve once the catalog
|
||||
// refreshes. (GH-1851; be-nx7 external-port test path)
|
||||
// following USE (implicit via DSN) fails with "Unknown database". This is
|
||||
// transient and resolves once the catalog refreshes. (GH-1851)
|
||||
if strings.Contains(errStr, "unknown database") {
|
||||
return true
|
||||
}
|
||||
if strings.Contains(errStr, "database not found") {
|
||||
return true
|
||||
}
|
||||
// Dolt internal race: after CREATE DATABASE, information_schema queries
|
||||
// on the new database may fail with "no root value found in session" if
|
||||
// the server hasn't finished initializing the database's root value.
|
||||
|
|
|
|||
|
|
@ -175,7 +175,6 @@ func testMainInner(m *testing.M) int {
|
|||
code = doltserver.ApplyLeakPolicy("internal/storage/dolt", code, swept)
|
||||
|
||||
testServerPort = 0
|
||||
os.Unsetenv("BEADS_DOLT_SERVER_PORT")
|
||||
os.Unsetenv("BEADS_DOLT_PORT")
|
||||
os.Unsetenv("BEADS_TEST_MODE")
|
||||
os.Unsetenv("BEADS_TEST_PDEATHSIG")
|
||||
|
|
|
|||
|
|
@ -331,8 +331,11 @@ func commitAllowEmpty(ctx context.Context, db doltBranchSQL, message string) err
|
|||
return nil
|
||||
}
|
||||
|
||||
// waitForDatabaseVisible polls USE <dbName> with exponential backoff until the
|
||||
// Dolt server reports the database as available. Bounded to ~10s — far longer
|
||||
// waitForDatabaseVisible polls USE <dbName> on db with exponential backoff
|
||||
// until the query succeeds. Success means the connection that ran it has
|
||||
// observed the server's catalog refresh for dbName — not a guarantee for
|
||||
// every connection in db's pool, and USE also mutates that connection's
|
||||
// session default database as a side effect. Bounded to ~10s — far longer
|
||||
// than any catalog-refresh window observed in practice — so a real failure
|
||||
// surfaces a clear error instead of hanging the test binary.
|
||||
func waitForDatabaseVisible(ctx context.Context, db *sql.DB, dbName string) error {
|
||||
|
|
@ -361,6 +364,9 @@ func waitForDatabaseVisible(ctx context.Context, db *sql.DB, dbName string) erro
|
|||
return ctx.Err()
|
||||
case <-time.After(delay):
|
||||
}
|
||||
// Cap is checked before doubling, so delay can reach ~1.6s (not 1s)
|
||||
// on the iteration that crosses the threshold; harmless within the
|
||||
// 10s bound above.
|
||||
if delay < time.Second {
|
||||
delay *= 2
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue