Skip to content

Revert Dolt lock cleanup workaround; fix embedded Dolt open via driver retries#1389

Merged
steveyegge merged 8 commits intosteveyegge:mainfrom
coffeegoddd:db/revert-and-fix
Jan 31, 2026
Merged

Revert Dolt lock cleanup workaround; fix embedded Dolt open via driver retries#1389
steveyegge merged 8 commits intosteveyegge:mainfrom
coffeegoddd:db/revert-and-fix

Conversation

@coffeegoddd
Copy link
Collaborator

@coffeegoddd coffeegoddd commented Jan 29, 2026

Summary

• Migrates Beads’ embedded Dolt backend to rely on dolthub/driver’s native open retries (via Config.BackOff) instead of
Beads-side lock contention workarounds.
• Refactors embedded initialization into explicit unit-of-work connectors so filesystem locks are reliably released between
setup steps (create DB, init schema, then open the long-lived store).
• Cleans up lock-contention scaffolding/documentation that existed only to paper over the old driver behavior.

Key changes

• Embedded connector lifecycle (critical):
• Introduces a UOW helper (internal/storage/dolt/embedded_uow.go) to ensure db.Close() and connector.Close() happen
together after each unit of work.
• Updates internal/storage/dolt/store.go to:
• Enable driver open retries with a bounded exponential backoff (MaxElapsedTime = 30s).
• Avoid “context poisoning” from short-lived open contexts by forcing the initial open/ping with a safe context.
• Ensure cleanup on failures (no leaked connector locks).
• Fix embedded path handling by using an absolute path when building file:// DSNs (prevents doubled paths like
.../.beads/dolt/.beads/dolt).
• Remove legacy lock-workaround material:
• Deletes the “Lock Contention” section from docs/DOLT-BACKEND.md (daemon-mode comment left untouched per prior
constraints).
• Repo hygiene / tooling:
• Updates GitHub Actions Go setup to follow the repository’s Go version automatically via go-version-file: 'go.mod'
(CI/nightly/release).
• Suppresses gosec G304 in cmd/bd/migrate_dolt.go with a scoped justification (postMergePath is derived from .git/hooks).

Why

• The embedded driver’s lock is owned by the connector’s engine, and database/sql does not close the connector for you.
Explicit UOW connector closure prevents leaked locks and makes multi-process contention predictable.
• Using the driver’s retry logic centralizes the correct behavior (and keeps Beads from accumulating bespoke lock
workaround code).

Test plan

• golangci-lint run ./...
• go test ./...

@coffeegoddd
Copy link
Collaborator Author

Fixes #1401

Copy link
Owner

@steveyegge steveyegge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well-engineered architectural improvement from the Dolt team. Replaces fragile lock-cleanup workarounds with proper driver-level retries and connector lifecycle management. Includes bug fixes for path-doubling and context poisoning. LGTM.

@steveyegge steveyegge merged commit 2c7e2d8 into steveyegge:main Jan 31, 2026
4 of 7 checks passed
groblegark pushed a commit to groblegark/beads that referenced this pull request Jan 31, 2026
…r retries (steveyegge#1389)

* Revert "fix(dolt): add lock retry and stale lock cleanup for operational reliability (steveyegge#1260)"

This reverts commit d037158.

* /{internal,go.mod,go.sum}: bump dolt driver, fix file after revert

* /{go,internal}: fix embedded dolt

* /{docs,internal}: fix path error

* /go.{mod,sum}: bump driver

* /{cmd,.github}: update workflows to pickup go.mod go version, fix lint error

* /.github/workflows/ci.yml: add icu4

* /{cmd,internal}: fix failing tests

---------

Co-authored-by: Test <[email protected]>
(cherry picked from commit 2c7e2d8)
groblegark pushed a commit to groblegark/beads that referenced this pull request Jan 31, 2026
…r retries (steveyegge#1389)

* Revert "fix(dolt): add lock retry and stale lock cleanup for operational reliability (steveyegge#1260)"

This reverts commit d037158.

* /{internal,go.mod,go.sum}: bump dolt driver, fix file after revert

* /{go,internal}: fix embedded dolt

* /{docs,internal}: fix path error

* /go.{mod,sum}: bump driver

* /{cmd,.github}: update workflows to pickup go.mod go version, fix lint error

* /.github/workflows/ci.yml: add icu4

* /{cmd,internal}: fix failing tests

---------

Co-authored-by: Test <[email protected]>
(cherry picked from commit 2c7e2d8)
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

Comments