Repository navigation
fix: agent replies stay refused with "admission is closed" after a failed operation cleanup until the gateway restarts - #159451
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 27, 2026, 3:02 AM ET / 07:02 UTC (Revision 4). ClawSweeper reviewWhat this changesThe branch lets an agent database execution owner retry failed native cleanup on a later request and adds worker-backed recovery tests. Merge readiness✅ Ready for maintainer review Current main still leaves an execution owner retired after native cleanup fails. This PR addresses that distinct failure path, and its worker-backed before-and-after evidence supports recovery without a Gateway restart. Priority: P0 Review scores
Verification
How this fits togetherAgent turns use a per-agent SQLite execution owner to admit database operations and manage a native worker and lease. Failed operations pass through that owner's cleanup before a later turn can use the database. flowchart LR
A[Agent request] --> B[Execution owner]
B --> C{Cleanup pending?}
C -->|Yes| D[Retry native cleanup]
C -->|No| E[SQLite worker]
D --> E
E --> F[Database result]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +10, Tests +219. Total +229 across 3 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep the failed generation and lease with one owner, retry native cleanup before new database work, and preserve terminal explicit revocation. Do we have a high-confidence way to reproduce the issue? Yes. The source and worker-backed fixture define a specific worker-exit plus lease-release-failure path; the PR body reports the admission refusal on main, although this read-only review did not execute it. Is this the best way to solve the issue? Yes. The repair stays in the existing execution owner, retries cleanup before replacement work, and preserves explicit revocation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cd481e80875d. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
Security-sensitive guard clearedCurrent revision: This PR no longer changes files in the maintainer security-review tier. Separate CODEOWNERS requirements still apply to security policy and enforcement files. |
…leanup When an agent-DB operation fails with an unavailable native store, run() calls owner.close(). close() sets retired = true before closeNative() settles and only evicts the owner from `executions` after a successful close, so a rejected native close (transient SQLITE_IOERR on the lease release) leaves a retired owner registered. Every later borrow() for that agent path then throws "Agent database execution admission is closed" until the process drains (gateway restart). The new test kills the SQLite worker mid-command and refuses the lease release while the fault is enabled, then expects the same agent to be re-admitted once the fault is gone. It fails on 2026.9.6 and current main with the production error text; the second case documents the scope (other agents unaffected, full drain clears it). Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01D2bGxAUAa1avrRxf5iU2iG
…d operation owner.close() marked the execution owner retired before its native close settled and only evicted it from `executions` after a successful close. When the close rejected (a transient SQLite I/O error on the lease release), the retired owner stayed registered for the agent path and every later borrow() was refused with "Agent database execution admission is closed" until the gateway restarted; nothing on the request path ever called close() again. Re-admit the owner when a non-revoked close fails. It keeps its generation, lease and cleanupFailure, so the next request retries the native close through the existing cleanup path before any new work and surfaces the native cause while it persists. Explicit revoke() stays terminal. The regression test now expects recovery and adds the retry-while-failing case (native cause instead of the generic refusal, then recovery once the cause clears). Closes openclaw#159438 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01D2bGxAUAa1avrRxf5iU2iG
c62623c to
9f9f80b
Compare
Current main hands the fixture admission a binding attachment; without it every prepare() is refused with "SQLite operation attachment is unavailable" before the scenario starts. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01D2bGxAUAa1avrRxf5iU2iG
|
Merged as f0423d5. Thank you @aspalagin for reporting this and contributing the fix and real-worker reproduction. Confirmed current main wedges after worker exit plus a failed lease release; the fix retains cleanup custody and allows the next native read after the fault clears. Successful close remains unchanged. Concurrent persistent-fault borrowers share one bounded cleanup attempt, receive the actual disk I/O error rather than an admission refusal, and do not accumulate live workers. All 46 focused lifecycle tests, selected consumer type graphs, and scoped lint/format checks passed. Fresh CI run 36301545164 and required gates were green, with hosted review ready on the exact merged head. CI selected and passed all three new cases in core-runtime-infra-storage-state-hosted-15: 1.877 s, 1.442 s, and 3.893 s (7.212 s total test time). |
…claw#159451) Closes openclaw#159438 Related: openclaw#157325 ## What Problem This Solves Fixes: every turn of an agent fails with `Agent database execution admission is closed` until the Gateway restarts when an agent database operation fails and its native cleanup also fails. ## User Impact User impact: the affected agent can use its database again on the next request after a transient cleanup failure clears, without a Gateway restart. Explicit resource revocation remains terminal. No configuration, schema, permissions, migration, or public API changes. ## Why This Change Was Made A failed native close left its execution owner permanently retired but still registered. Re-admitting the non-revoked owner preserves custody of its native generation and lease: later operations retry cleanup before replacement work is allowed. The native close waits for the stopped worker before releasing its retained lease, and a failed lease-release attempt still closes its cleanup worker. No failed user operation is replayed. No overlap with Pash/Sarah changes. ## Evidence Real execution owner and SQLite workers, with worker exit injected during a marked operation and `disk I/O error` injected at lease release: - Main `45d46000df1d`: both failure/recovery cases fail with `Agent database execution admission is closed` after the operation and cleanup fail. - Candidate: all three cases pass. Failed-close recovery performs a real `session.entry.read` successfully after the fault clears. - Successful-close control passes on both main and the candidate: a worker exit without the lease-release failure does not wedge the agent. - Persistent fault: two rounds of two concurrent borrowers each share exactly one cleanup attempt. Every borrower receives `disk I/O error`, not `admission is closed`; the tracked live-worker count stays constant. Once the fault clears, the very next native read succeeds. Another agent remains usable. - The retained logical owner remains registered throughout failed cleanup, so concurrent borrowers cannot install another owner for that path. Replacement native generation creation remains behind successful cleanup. - The new file is selected by `vitest.infra.config.ts` through `databaseWorkerCoreTestFiles`; the repository test wrapper ran it as `|infra|`. Command: `node scripts/run-vitest.mjs src/state/openclaw-agent-execution.close-wedge.test.ts --maxWorkers=1`. Measured candidate cost on macOS arm64: 9.00 s Vitest, 28.60 s whole invocation including worker bundle preparation; cases 1.96 s, 1.32 s, and 2.95 s. No sleeps or polling; real worker lifecycle is needed to exercise native retirement and lease cleanup. Gap: this reproduces the recovery failure with injected native faults, not the original filesystem cause of the production I/O error. No isolated Gateway/provider turn is claimed. Final focused lifecycle run: 4 files, 46 tests passed (`close-wedge`, `integrity`, `creation-witness`, and `execution-cleanup`), 30.79 s Vitest / 45.67 s command. Scoped Oxlint, formatting, diff whitespace checks, and all consumer type graphs selected for the execution owner passed. Co-authored-by: Arseniy Palagin <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…claw#159451) Closes openclaw#159438 Related: openclaw#157325 Fixes: every turn of an agent fails with `Agent database execution admission is closed` until the Gateway restarts when an agent database operation fails and its native cleanup also fails. User impact: the affected agent can use its database again on the next request after a transient cleanup failure clears, without a Gateway restart. Explicit resource revocation remains terminal. No configuration, schema, permissions, migration, or public API changes. A failed native close left its execution owner permanently retired but still registered. Re-admitting the non-revoked owner preserves custody of its native generation and lease: later operations retry cleanup before replacement work is allowed. The native close waits for the stopped worker before releasing its retained lease, and a failed lease-release attempt still closes its cleanup worker. No failed user operation is replayed. No overlap with Pash/Sarah changes. Real execution owner and SQLite workers, with worker exit injected during a marked operation and `disk I/O error` injected at lease release: - Main `aaf0be1026c4`: both failure/recovery cases fail with `Agent database execution admission is closed` after the operation and cleanup fail. - Candidate: all three cases pass. Failed-close recovery performs a real `session.entry.read` successfully after the fault clears. - Successful-close control passes on both main and the candidate: a worker exit without the lease-release failure does not wedge the agent. - Persistent fault: two rounds of two concurrent borrowers each share exactly one cleanup attempt. Every borrower receives `disk I/O error`, not `admission is closed`; the tracked live-worker count stays constant. Once the fault clears, the very next native read succeeds. Another agent remains usable. - The retained logical owner remains registered throughout failed cleanup, so concurrent borrowers cannot install another owner for that path. Replacement native generation creation remains behind successful cleanup. - The new file is selected by `vitest.infra.config.ts` through `databaseWorkerCoreTestFiles`; the repository test wrapper ran it as `|infra|`. Command: `node scripts/run-vitest.mjs src/state/openclaw-agent-execution.close-wedge.test.ts --maxWorkers=1`. Measured candidate cost on macOS arm64: 9.00 s Vitest, 28.60 s whole invocation including worker bundle preparation; cases 1.96 s, 1.32 s, and 2.95 s. No sleeps or polling; real worker lifecycle is needed to exercise native retirement and lease cleanup. Gap: this reproduces the recovery failure with injected native faults, not the original filesystem cause of the production I/O error. No isolated Gateway/provider turn is claimed. Final focused lifecycle run: 4 files, 46 tests passed (`close-wedge`, `integrity`, `creation-witness`, and `execution-cleanup`), 30.79 s Vitest / 45.67 s command. Scoped Oxlint, formatting, diff whitespace checks, and all consumer type graphs selected for the execution owner passed. Co-authored-by: Arseniy Palagin <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit f0423d5)
Closes #159438
Related: #157325
What Problem This Solves
Fixes: every turn of an agent fails with
Agent database execution admission is closeduntil the Gateway restarts when an agent database operation fails and its native cleanup also fails.User Impact
User impact: the affected agent can use its database again on the next request after a transient cleanup failure clears, without a Gateway restart. Explicit resource revocation remains terminal. No configuration, schema, permissions, migration, or public API changes.
Why This Change Was Made
A failed native close left its execution owner permanently retired but still registered. Re-admitting the non-revoked owner preserves custody of its native generation and lease: later operations retry cleanup before replacement work is allowed. The native close waits for the stopped worker before releasing its retained lease, and a failed lease-release attempt still closes its cleanup worker. No failed user operation is replayed.
No overlap with Pash/Sarah changes.
Evidence
Real execution owner and SQLite workers, with worker exit injected during a marked operation and
disk I/O errorinjected at lease release:aaf0be1026c4: both failure/recovery cases fail withAgent database execution admission is closedafter the operation and cleanup fail.session.entry.readsuccessfully after the fault clears.disk I/O error, notadmission is closed; the tracked live-worker count stays constant. Once the fault clears, the very next native read succeeds. Another agent remains usable.vitest.infra.config.tsthroughdatabaseWorkerCoreTestFiles; the repository test wrapper ran it as|infra|.Command:
node scripts/run-vitest.mjs src/state/openclaw-agent-execution.close-wedge.test.ts --maxWorkers=1. Measured candidate cost on macOS arm64: 9.00 s Vitest, 28.60 s whole invocation including worker bundle preparation; cases 1.96 s, 1.32 s, and 2.95 s. No sleeps or polling; real worker lifecycle is needed to exercise native retirement and lease cleanup.Gap: this reproduces the recovery failure with injected native faults, not the original filesystem cause of the production I/O error. No isolated Gateway/provider turn is claimed.
Final focused lifecycle run: 4 files, 46 tests passed (
close-wedge,integrity,creation-witness, andexecution-cleanup), 30.79 s Vitest / 45.67 s command. Scoped Oxlint, formatting, diff whitespace checks, and all consumer type graphs selected for the execution owner passed.