Skip to content

fix(sessions): preserve rollback-journal commit waits - #160887

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-entry-commit-compat-20260929
Sep 29, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-entry-commit-compat-20260929

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Follow-up to #160801: a rollback-journal reader could make a session patch fail immediately at COMMIT, even if it released the read lock within the existing busy timeout.

User Impact

Session patches retain nonblocking write-lock admission and regain the existing bounded commit wait on rollback-journal storage. Schemas, configuration, durability, and update behavior are unchanged. Commit waiting remains synchronous and retains its existing bounded policy.

Why This Change Was Made

The existing admission helper temporarily sets a zero timeout for BEGIN, then restores the original connection policy before the synchronous callback and COMMIT. The adapter's redundant outer zero-timeout scope made that restoration restore zero. Remove that override and report the actual original policy in diagnostics. FIFO, connection/authority checks, synchronous callbacks, and non-replay stay with their existing owners.

Evidence

Blacksmith Testbox (blacksmith-testbox, openclaw-check) lease tbx_01m3nbpgcvkhfchrjnwhjkhqkq (run):

  • The permanent real session-patch regression failed before the fix (native timeout 0 instead of the configured 37 ms) and passed afterward, with a second rollback-journal reader and a separate-connection durability assertion. It adds no timers, polling, processes, or production test seams.
  • A separate, uncommitted native-wait probe held a reader in another process, releasing it 100 ms after writer admission. Before: SQLITE_BUSY after 9.3 ms, unchanged row, one callback. After: committed after 109.0 ms, updated row, one callback, original 5,000 ms budget retained. The timer exists only in this one-off proof, not the CI regression.
  • 88 focused entry/admission/environment/transaction tests passed, including the existing event-loop responsiveness regression.

The original performance measurement remains 262.19 ms → 0.94 ms event-loop callback delay under writer contention. This follow-up changes only the admitted write/commit policy, retaining the yielding BEGIN path.

Independent Codex autoreview is scoped-clean with no actionable P0–P2 findings. node scripts/check-changed.mjs --base d4be6500114cff6fcbf72f323fc520861a06c6c9 -- <three changed paths> and pnpm lint:tmp:sqlite-transaction-boundary both passed, including all selected core test typecheck shards.

Measured cost: pnpm test src/config/sessions/session-accessor.sqlite-entry-revalidation.test.ts --maxWorkers=1 passed 38 tests in 11.35 s wall (the added case: 118 ms including fixture). The Testbox lease is stopped.

Follow up #160801. Keep BEGIN admission yielding while restoring the original native timeout before the synchronous write and COMMIT, so session patches retain their bounded chance to commit after a rollback-journal reader finishes.
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XS labels Sep 29, 2026
@steipete
steipete enabled auto-merge (squash) September 29, 2026 02:01
@clawsweeper

clawsweeper Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 10:03 PM ET / September 29, 2026, 02:03 UTC.

ClawSweeper review

What this changes

The PR restores the SQLite connection’s bounded commit wait for session-entry patches, adds a regression case, and updates the database-access documentation.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still has the commit-time timeout problem, and the merged writer-admission PR does not cover this rollback-journal case. The proposed repair is narrow and remains useful.

Priority: P2
Reviewed head: 1b0cd1ff2b92f5646342c15917b08dbe2a06ec7f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A small owner-level repair has a credible native before-and-after observation and focused regression coverage, with the runtime trace available here through the PR body.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body reports a Blacksmith Testbox probe through the session-patch entrypoint with a real second-process rollback-journal reader: after the fix, COMMIT persisted the changed row after 109.0 ms, versus SQLITE_BUSY and an unchanged row before. The permanent test separately verifies timeout restoration and durability; linked run logs were unavailable to this reviewer. No stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body reports a Blacksmith Testbox probe through the session-patch entrypoint with a real second-process rollback-journal reader: after the fix, COMMIT persisted the changed row after 109.0 ms, versus SQLITE_BUSY and an unchanged row before. The permanent test separately verifies timeout restoration and durability; linked run logs were unavailable to this reviewer. No stored-data contract changes.
Evidence reviewed 8 items Introduced repair: The PR removes the outer zero-timeout scope; the session writer now lets the transaction helper restore the connection policy before the synchronous write and commit.
Current-main behavior: Fetched main still wraps the admitted write and COMMIT in a zero busy timeout, so the requested behavior is not already implemented there.
Transaction owner: The existing helper temporarily sets zero timeout for BEGIN and calls restore before the admitted operation; it retries only failures before entry.
Findings None None.
Security None None.

How this fits together

Session-entry patches turn agent activity into rows in an agent’s SQLite database. A writer queue admits each patch, SQLite commits it, and post-commit publications refresh session state.

flowchart LR
 A[Session patch] --> B[Writer queue]
 B --> C[SQLite writer admission]
 C --> D[Session row update]
 D --> E[SQLite commit]
 E --> F[Published session state]
 G[Connection timeout] --> C
 G --> E
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -2, Tests +33, Docs +2. Total +33 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 6 -2
Tests 1 33 0 +33
Docs 1 5 3 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 42 9 +33

Review metrics

Metric Value Why it matters
Commit wait policy 0 ms → connection timeout; 5,000 ms default The restored wait can let a rollback-journal reader finish, while COMMIT remains synchronous.
Regression cost 1 added case; 118 ms case, 11.35 s file wall The PR reports the per-PR test cost required by the repository’s test policy.

Technical review

Best possible solution:

Preserve yielding BEGIN admission and the connection’s bounded COMMIT policy within the existing session writer owner.

Do we have a high-confidence way to reproduce the issue?

Yes. Current-main source shows why a rollback-journal reader can make COMMIT fail immediately, and the PR reports a before-and-after native probe; this reviewer did not execute it.

Is this the best way to solve the issue?

Yes. Removing the redundant outer timeout scope lets the existing transaction owner restore the connection policy without changing queueing, authority checks, or stored data.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6b3033b65ca9.

Labels

Label changes:

  • add P2: A rollback-journal session patch can fail prematurely, but the demonstrated scope is limited and the affected adapter is not in the cited latest release.
  • add merge-risk: 🚨 availability: The documented repair restores a bounded synchronous COMMIT wait on the calling thread when a rollback-journal reader holds a lock.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports a Blacksmith Testbox probe through the session-patch entrypoint with a real second-process rollback-journal reader: after the fix, COMMIT persisted the changed row after 109.0 ms, versus SQLITE_BUSY and an unchanged row before. The permanent test separately verifies timeout restoration and durability; linked run logs were unavailable to this reviewer. No stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.

Label justifications:

  • P2: A rollback-journal session patch can fail prematurely, but the demonstrated scope is limited and the affected adapter is not in the cited latest release.
  • merge-risk: 🚨 availability: The documented repair restores a bounded synchronous COMMIT wait on the calling thread when a rollback-journal reader holds a lock.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports a Blacksmith Testbox probe through the session-patch entrypoint with a real second-process rollback-journal reader: after the fix, COMMIT persisted the changed row after 109.0 ms, versus SQLITE_BUSY and an unchanged row before. The permanent test separately verifies timeout restoration and durability; linked run logs were unavailable to this reviewer. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 5d60562 adds src/state/openclaw-agent-db-transaction.ts:58 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5d605627c500; files: src/state/openclaw-agent-db-transaction.ts)
  • RoboClaw: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit c2feb35 into main Sep 29, 2026
218 of 219 checks passed
@steipete
steipete deleted the steipete/perf-micro-entry-commit-compat-20260929 branch September 29, 2026 02:18
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
Follow up openclaw#160801. Keep BEGIN admission yielding while restoring the original native timeout before the synchronous write and COMMIT, so session patches retain their bounded chance to commit after a rollback-journal reader finishes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant