Skip to content

fix(outbox): prune delivered rows inside the add's write transaction - #535

Merged
andrebrait merged 1 commit into
mainfrom
fix/outbox-prune-in-add-transaction
Nov 18, 2026
Merged

andrebrait merged 1 commit into
mainfrom
fix/outbox-prune-in-add-transaction

Conversation

@andrebrait

@andrebrait andrebrait commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Every outbox add ran pruneDelivered as its own autocommit DELETE before
the add's BEGIN IMMEDIATE transaction, so it took the database's write
lock twice. With several server processes adding at once, the
housekeeping DELETE could wait past busy_timeout and fail the whole add
with a 500 ("database is locked"), seen on the Windows CI runner in
"concurrent processes share the 1000-row active pool". The prune now
runs first inside the add's own transaction: one write lock per add, in
the same order as before.

Summary by CodeRabbit

  • Bug Fixes
    • Improved consistency when adding messages to the outbox: delivered entries are now cleaned up as part of the add operation. This helps keep outbox updates coordinated and reduces the chance of cleanup occurring separately from a failed or interrupted addition.

Every outbox add ran pruneDelivered as its own autocommit DELETE before
the add's BEGIN IMMEDIATE transaction, so it took the database's write
lock twice. With several server processes adding at once, the
housekeeping DELETE could wait past busy_timeout and fail the whole add
with a 500 ("database is locked"), seen on the Windows CI runner in
"concurrent processes share the 1000-row active pool". The prune now
runs first inside the add's own transaction: one write lock per add, in
the same order as before.
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

runOutboxCommand now prunes delivered entries inside the add operation’s immediate transaction instead of deleting them before the transaction.

Changes: Outbox add operation

Layer / File(s) Summary
Prune delivered entries within add transaction
lib/message-outbox.ts
runOutboxCommand starts the transaction before pruning delivered entries. Pruning and the add operation use the same write lock.

Estimated code review effort: 1 (Trivial) | ~4 minutes

Change: Bug fix

Merge Risk: Minimal · up to 9a980

Pruning delivered outbox rows now happens inside the add's single write transaction, which should avoid "database is locked" failures when several processes add concurrently. No concrete merge-blocking risk was found.

Security architecture risk: Minimal · up to 9a980

The change consolidates pruning and message admission under one write transaction without expanding access or changing message ownership checks. No introduced or worsened security or failure-containment risk was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — Pruning operates across sessions sharing the same outbox database, and admission uses global active-entry limits. This shared-store scope already existed; the change consolidates its transaction boundary rather than expanding the deletion scope.

Trust Boundaries and Controls

  • observed — Within the inspected entrypoint, command-supplied origin is rejected, installation scope and input constraints are checked before admission, and existing identifiers are checked against session membership both before and inside the transaction. The comparison does not move or remove these controls or change the supplied owner and advisor parameters.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the change: delivered-row pruning now runs inside the add operation's write transaction, which matches the raw summary (pruning moved from a separate autocommit DELETE into the BEGIN I…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change: delivered-row pruning now runs inside the add operation's write transaction, which matches the raw summary (pruning moved from a separate autocommit DELETE into the BEGIN IMMEDIATE transaction) and the PR objective of using one write lock per add. The title is specific and concise, and the 68-character length is within normal bounds. It does not mention the lock-timeout symptom, but it does not need to.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

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: 3dc95812-81c8-4494-a92b-38f8b5b1abbb
Commits

Reviewing files that changed from the base of the PR and between 7fe50eb and 9a980c0.

Files selected for processing: 1

  • lib/message-outbox.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@andrebrait
andrebrait merged commit 346e193 into main Nov 18, 2026
5 checks passed
andrebrait added a commit that referenced this pull request Nov 18, 2026
Bumps the version to 0.7.3 and folds [Unreleased] into [v0.7.3]: the Windows tray built at release (#530), resumable omp runner downloads (#531), the normal update of an old linked host (#533) and one write lock per outbox add (#535).
@andrebrait
andrebrait deleted the fix/outbox-prune-in-add-transaction branch November 18, 2026 23:08
andrebrait added a commit to ompweb-dev/tau that referenced this pull request Nov 23, 2026
* fix(windows): let in-app updates replace an npm-global install

Port of ompweb-dev/ompweb#519.

* fix(windows): stop a failed host candidate that got the old daemon's pid

Port of ompweb-dev/ompweb#526.

* fix(outbox): prune delivered rows inside the add's write transaction

Port of ompweb-dev/ompweb#535.

* fix(windows): find the host's scheduled task without administrator rights

Port of ompweb-dev/ompweb#539.

* fix(updates): build the tray at release and resume host update downloads

Port of ompweb-dev/ompweb#532. The committed bin/tau-tray.exe was still the omp-web build; releases now build it from native/tray. The omp runner download resume does not apply: tau has no runner download.

* fix(hosts): report pi to the server once it answers after the daemon started

Port of ompweb-dev/ompweb#542. A daemon whose startup read found no pi reads the version again (30 s, doubling to 5 min) and sends a pi_version link message, so a host that gets pi after its daemon started comes online without a restart. The runner download retry does not apply: tau has no runner download.

* docs(agents): note the pi_version link message

* fix(chat): count only completed subagents in the subagents header

Port of ompweb-dev/ompweb#440.

* feat(chat): render svg code fences inline

Port of ompweb-dev/ompweb#455.

* fix(sidebar): mark a completed session seen once it is opened

Port of ompweb-dev/ompweb#336.

* fix(i18n): add the zh-TW completed-subagents summary

Port of ompweb-dev/ompweb#545.

* perf(sessions): strip unused assistant fields from the session response

Port of ompweb-dev/ompweb#454.

* feat(api): app-info handshake and a per-connection heartbeat

Port of ompweb-dev/ompweb#407.

* feat(directory-picker): add a Browse… button that opens the OS folder dialog

Port of ompweb-dev/ompweb#544.

* feat(sessions): navigation-only reads, context ETag and a prompt-less state

Port of ompweb-dev/ompweb#415. A rename now falls back to pi's session_info entry only when pi refused it or the child is gone.

* feat(notifications): answer a pending dialog from the notification

Port of ompweb-dev/ompweb#414, without omp's formDialog and session-move aliases.

* perf(events): hold tool snapshots to one frame per second

Port of ompweb-dev/ompweb#418.

* fix(ui): prevent file-panel tabs from clipping on overflow

Port of ompweb-dev/ompweb#547.

* fix(projects): keep a re-added workspace's display data and avoid worktree path collisions

Port of ompweb-dev/ompweb#554 (rework of ompweb-dev/ompweb#297).

* feat(composer): fullscreen edit mode and one-line collapse for long sent messages

Port of ompweb-dev/ompweb#556.

* docs(changelog): note the ports from ompweb

* chore: use tau names in the ported update and tray code

* fix(markdown): sanitize svg fences with an element allowlist

A tab inside the scheme (java&#9;script:), a prefixed xlink href, <set>/<animate> retargeting an href, and CDATA or processing instructions re-parsed as HTML on insertion all got past the blocklist sanitizer.

* fix(directory-picker): offer the folder dialog only to a page on this machine

Behind a reverse proxy on this machine every connection is loopback, so the page's own Origin (or same-origin Referer) must be loopback too. The picker can be closed while a dialog is pending, and the zenity check runs once.

* fix(composer): queue or steer from the full-screen editor during a run

Send and Ctrl+Enter called handleSend, which ignores a message while a run streams, so the editor closed and nothing was sent.

* fix(notifications): keep a shared child's dialogs announceable after this server leaves it

Leaving a host-owned child that keeps running retracted its pending dialogs permanently, so the next holder could not announce a question that was still waiting. They are now forgotten (a temporary retraction), as after a resync.

* docs(notifications): drop omp-only dialog kinds from the ported comments

* fix(dialogs): answer pi's dialogs under their own ids and show the ask tool's questions

The wrapper still accepted only omp's numeric dialog ids, so every answer to a pi dialog (UUID ids) failed with invalid_ui_response, from the web dialog and from a notification. The ask tool's payload ({questions: [{question, options: string[], multiSelect}]}) reached the dialog unconverted, which expects a question list with option objects; RpcProcess now converts it.

* fix(tray): read tau's settings and logs from ~/.pi/agent

The native tray still read ~/.omp/agent/web-service.json and its logs, so it ignored the saved port, hostname and mode. Releases now build this source (scripts/build-tray.sh).

* fix(hosts): never build the local link URL from an unbracketed IPv6 address

* test(notifications): name the registry-key answer test for what it checks

* test(hosts): give the fake children pi's string dialog ids

* fix(dialogs): keep host tool calls out of dialog answers, and settle a dead child's dialogs for good

A ui_response naming a pending host tool call is refused, so its bookkeeping sees the real host_tool_result. Dialogs are only forgotten when this server leaves a shared child that is still alive. The ask tool's questions get distinct ids, and pageIsLoopback sits above handle's doc comment.

* fix(events): stop releasing held tool snapshots once the sink falls behind

* fix(composer): paste images and leave IME keys alone in the full-screen editor

* fix(directory-picker): require Origin on a non-GET, and read the Windows chooser's path as UTF-8

* fix(worktrees): report an occupied fallback worktree directory as worktree_directory_exists

* fix(notifications): keep pushes within 3993 bytes, refuse expired dialogs and settled replays

* fix(updates): release only the stopped server's own processes and recheck each pid before stopping it

* docs(notifications): name the /api/events notifications channel

* fix(updates): release every install locker after the server stops again

Scoping that release to the stopped trees missed their children on Linux and macOS, where a dead parent's children are re-parented, so the leftover check refused the update.

* fix(notifications): keep the question in a push that drops its dialog, and close expired dialogs in open tabs

* fix(updates): skip a locker whose re-listing fails; document the notifications subscribe body

* fix(updates): fail the install cleanup when a re-listing fails

Skipping the locker let rollback take an unfinished cleanup as done and restore the installation while a runtime still ran from it.

* fix(notifications): do not carry a request id past the dialog id limit

pi's ids are UUIDs; an oversized one could take the push past 3993 bytes on its own.
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