Skip to content

fix(db): recover stuck sqlx transaction-depth counter in begin_immediate - #361

Merged
aliasfoxkde merged 6 commits into
mainfrom
fix/db-depth-unwind
Nov 2, 2026
Merged

aliasfoxkde merged 6 commits into
mainfrom
fix/db-depth-unwind

Conversation

@aliasfoxkde

Copy link
Copy Markdown
Owner

Summary

  • Direction-2 connection poisoning: sqlx depth counter stuck above zero with no live Transaction owner rejects every custom-statement begin_with before reaching SQLite; raw ROLLBACK recovery (direction 1) cannot fix it.
  • begin_immediate now unwinds the counter with managed SAVEPOINT begin/rollback passes, holding the connection out of the pool during the unwind.
  • Regression test reproduces the live 2026-11-02 pipeline-activation failure (5x non-zero transaction depth while healthy runs kept serving the same pool).

Test plan

  • New regression test test_begin_immediate_unwinds_stuck_depth_counter passes
  • Full gitforge-db unit suite: 109 passed
  • cargo clippy -p gitforge-db --all-targets -- -D warnings clean
  • cargo fmt --all -- --check clean
  • GitForge CI pipeline green on this branch

aliasfoxkde and others added 6 commits October 30, 2026 10:56
The deployed binary on 192.168.1.202 (69245e2 bundle, Oct 29) predates
the job-level environment field; its parser rejects the key (fail-closed
per 0857218), so every push event for 7f4e8fd failed with 'unknown job
key environment'. The top-level environment: {} remains — that one the
deployed parser requires and accepts.
Clippy (rust 1.99 in dsc-ci-rust:12) flags the manual str::repeat
pattern as manual_str_repeat/manual_repeat_n under -D warnings.

Co-Authored-By: Claude <noreply@anthropic.com>
A busy branch occupied its repository's FIFO trigger lane for the
whole of each ~10-minute pipeline, leaving other refs of the same
repo starved: five main-branch trigger requests sat pending for
hours while codex-branch pushes kept re-arming the lane, and the
republish redrive could not help because it re-queued into the
same lane. Lane keys now include the ref name, so ordering holds
within a ref while cross-ref starvation is impossible.
sqlx's per-connection depth counter can desync in two directions. The
2026-10-08 fix (bare ROLLBACK probe) handles the SQLite-side orphan, but
the counter-side direction - depth stuck above zero with no live
Transaction owner - rejected every begin_with carrying a custom
statement with "attempted to call begin_with at non-zero transaction
depth" before any statement reached SQLite. Raw ROLLBACK cannot fix
that direction: the counter only moves through sqlx's managed commands.

Live 2026-11-02: every pipeline-activation trigger failed five times
with the depth error while healthy runs kept serving from the same
pool, so an OpenCodifier commit sat un-run for hours.

begin_immediate now detects the depth-error signature and unwinds the
counter with a managed begin/rollback pair (SAVEPOINT at depth > 0,
decrement on rollback) before retrying. Regression test injects the
stuck state on a single-connection pool, mirroring the deterministic
MRU re-handout that made every retry fail.
@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7a89ded4-b1e9-4deb-8820-e5049911e6ee
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@aliasfoxkde
aliasfoxkde merged commit 22fe4c1 into main Nov 2, 2026
25 checks passed
@aliasfoxkde
aliasfoxkde deleted the fix/db-depth-unwind branch November 2, 2026 06:58
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

🤖 AI Code Review Results

AI review skipped: provider 'anthropic' is not configured; deterministic gates remain authoritative.

✅ No critical issues found.

AI Code Review powered by GitForge

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