8000 fix(db): calls inside a WriteTransaction return INT-001 instead of deadlocking (#734) by adityamukho · Pull Request #739 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

fix(db): calls inside a WriteTransaction return INT-001 instead of deadlocking (#734) - #739

Merged
adityamukho merged 4 commits into
v3from
fix/734-tx-guards
Oct 24, 2026
Merged

adityamukho merged 4 commits into
v3from
fix/734-tx-guards

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

Problem (#734)

checkpoint, verify and rebuild_indexes took inner.write_lock without the is_write_tx_active() check that execute, query, fact_log and begin_write make. Called on a thread that holds a WriteTransaction, each one locked a mutex its own thread already held, and hung.

Fix

  • The INT-001 check is added to checkpoint, verify, rebuild_indexes, prepare, PreparedQuery::execute and PreparedQuery::query. The last three could not deadlock, but they ran inside the transaction where execute/query refuse.
  • is_write_tx_active is now pub(crate) so prepared.rs can use it.
  • This is PR 0 of the Expose UDF registration in every binding #180 plan (docs/superpowers/plans/2026-10-24-180-udf-uniffi.md, steps 1–3). Expose UDF registration in every binding #180's re-entry rules depend on these guards.

Tests

tests/write_tx_guard_test.rs has one test per method. Each runs on a thread that holds a WriteTransaction on a file database, inside a 30 s recv_timeout, so a deadlock fails the test instead of hanging CI. Each expects INT-001, then checks that the transaction still commits. A further test checks that the calls still run outside a transaction.

Before the fix: checkpoint, verify and rebuild_indexes timed out, and the three prepared calls returned Ok.

Bench machine: default features 1,710 passed / 13 ignored; --features test-hooks 1,726 / 14 (each +7). One earlier test-hooks run stopped at a single failure. I didn't capture which test it was, and it didn't reproduce in the --no-fail-fast rerun. cargo clippy --all-features -D warnings is clean.

Docs

ERROR_REFERENCE INT-001 (the methods that raise it), CHANGELOG Fixed, TEST_COVERAGE, CLAUDE.md counts. A main backport PR follows. #734 stays open until that v2.x patch is published.

🤖 Generated with Claude Code

https://claude.ai/code/session_015NBT2Yx9JUQKYvv2CvC9py

…adlocking (#734)

checkpoint, verify and rebuild_indexes locked the write lock their own
thread's WriteTransaction held, and hung. They now check, as execute,
query, fact_log and begin_write do; prepare and PreparedQuery::execute/
query get the same check for consistency.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015NBT2Yx9JUQKYvv2CvC9py
…cked thread

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015NBT2Yx9JUQKYvv2CvC9py
@codecov
codecov Bot commented Oct 24, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

# Conflicts:
#	CLAUDE.md
#	docs/TEST_COVERAGE.md
# Conflicts:
#	CLAUDE.md
#	docs/TEST_COVERAGE.md
@adityamukho
adityamukho merged commit 7f90e95 into v3 Oct 24, 2026
19 checks passed
@adityamukho
adityamukho deleted the fix/734-tx-guards branch October 24, 2026 09:31
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.

1 participant

0