Skip to content

Conversation

@coffeegoddd
Copy link
Contributor

This PR makes the embedded Dolt database/sql driver resilient to multi-process contention by adding configurable retries with backoff and ensuring retries reopen
the underlying Dolt SQL engine so connections don’t get stuck in a read-only/fallback state.

Key changes

• Retry policy via DSN params: retry, retrytimeout, retrymaxattempts, retryinitialdelay, retrymaxdelay.
• Embedded-mode tuning DSN params:
• nocache=true to disable Dolt’s in-process singleton DB cache during embedded opens
• failonlocktimeout=true to fail fast on journal lock timeout (avoids silent read-only fallback)
• Retry logic:
• Retries now apply to engine open (so Ping() / first connect can succeed after contention clears)
• Retries apply to statement execution (reopen engine + backoff + retry on retryable errors)
• Engine reopen support:
• DoltConn stores datasource + retry policy, uses a mutex, can rebuild se + gmsCtx
• Statements/transactions reference the connection and always fetch the current engine/context
• Error classification:
• Adds conservative retryable detection (including Dolt’s new nbs.ErrDatabaseLocked).
• Tests:
• New multi-process contention tests (concurrency_lock_test.go) covering:
• no-retry fast failure under contention
• retry-enabled eventual success after lock release

@coffeegoddd coffeegoddd requested review from reltuk and zachmu January 24, 2026 15:46
@coffeegoddd coffeegoddd deleted the db/retry branch January 29, 2026 21:06
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.

2 participants