Repository navigation
fix: avoid Gateway stalls when renaming sessions - #147869
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: blocked before merge. Reviewed September 14, 2026, 3:25 AM ET / 07:25 UTC (Revision 5). ClawSweeper reviewWhat this changesAdds an index to accelerate session rename checks, optimizes large plaintext rendering, defers session-setup translations, and adjusts supporting tests and schema documentation. Merge readiness⛔ Blocked before merge - 1 item remains This PR remains useful: current main lacks the label index, and merged adjacent performance fixes do not replace it. No blocking introduced defect was found; the earlier storage compatibility concerns have supporting approval and upgrade evidence. Priority: P2 Review scores
Verification
How this fits togetherGateway session renames check existing labels in each agent’s SQLite database before committing an update. The Control UI separately renders replies and loads translated session-setup text. flowchart TD
A[Session rename request] --> B[Existing label checks]
C[Agent database label index] --> B
B --> D[Validated session update]
E[Large reply text] --> F[Plain text nodes]
F --> G[Existing sanitizer]
G --> H[Control UI transcript]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +16, Tests +105, Docs +10, Generated 0, Other +14. Total +145 across 19 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep label lookup acceleration inside the existing schema owner while preserving canonical session data, collision checks, and rollback compatibility. Do we have a high-confidence way to reproduce the issue? Yes: current main retains the unindexed label-owner query, and the supplied built-Gateway comparison exercises renames against 3,550 sessions. This read-only review did not execute a fresh reproduction. Is this the best way to solve the issue? Yes: the covering index accelerates the existing query through its existing schema lifecycle, and the accepted design records why the measured SQL-only alternative was insufficient. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b2fefda199c6. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
|
The storage compatibility requirement in review revision 5 is complete and was verified before landing. Fresh Package Acceptance passed for package source The exact tarball ( Final required CI passed on the exact attempted head, and the native maintainer workflow confirmed the merge. Complete prior-candidate and subsequent delta reviews were clean through P2. The matched Gateway CPU/RPC measurements remain pinned to |
f38248d to
0e9f819
Compare
Use the original persisted expiry as the resume assertion deadline. The default poll timeout equals the worker heartbeat interval, so its final sample can miss a valid renewal before expiry after lifecycle contention. Preserve the exclusion and final ownership assertions. A baseline phase probe reproduced the false failure; the corrected phase and all 16 heartbeat cases pass on base and candidate.
80bd0d4 to
55b6ad7
Compare
|
Merged via squash.
|
* commit '8e6fe8e02ddb51bfec4e80071f0f2adcae4cf098': (47 commits) refactor: simplify Gateway health response parsing (#147834) fix: avoid Gateway stalls when renaming sessions (#147869) refactor(plugins): reuse worker optional-method validation (#147925) refactor(infra): remove unreachable firewall diagnostic fallback (#147882) fix(ui): open attached automations from session hovercards (#147749) refactor(reply): share usage-bar numeric coercion (#147863) fix(doctor): report warnings for keyed agent configs (#123058) perf(plugins): reuse complete registry comparisons (#147893) fix(workboard): await lifecycle sweep completion in tests (#147950) fix: reduce stalls when browsing large session inventories (#147911) refactor(onboard): share custom model definition (#147915) feat(ios): collapse completed chat work above replies (#148002) fix(voice-call): retain state runtime for deferred streams (#147689) test(qa): compare Telegram entities semantically (#147752) fix(plugins): preserve runtime scope for deferred CLI actions (#147688) test(qa): keep Slack progress marker visible (#147748) test(qa): finish channel picker prompts (#147730) test(tui): handle auth restriction prompt (#147729) fix(qa): retain onboarding prompts across redraw bursts (#147687) fix(qa): seed Teams ambiguous timeout deterministically (#147686) ...
* commit '069710f909f0a7158777d0fc0bf1eab84e20c699': (45 commits) refactor(infra): consolidate update campaign reset ownership (openclaw#146555) refactor: simplify Gateway health response parsing (openclaw#147834) fix: avoid Gateway stalls when renaming sessions (openclaw#147869) refactor(plugins): reuse worker optional-method validation (openclaw#147925) refactor(infra): remove unreachable firewall diagnostic fallback (openclaw#147882) fix(ui): open attached automations from session hovercards (openclaw#147749) refactor(reply): share usage-bar numeric coercion (openclaw#147863) fix(doctor): report warnings for keyed agent configs (openclaw#123058) perf(plugins): reuse complete registry comparisons (openclaw#147893) fix(workboard): await lifecycle sweep completion in tests (openclaw#147950) fix: reduce stalls when browsing large session inventories (openclaw#147911) refactor(onboard): share custom model definition (openclaw#147915) feat(ios): collapse completed chat work above replies (openclaw#148002) fix(voice-call): retain state runtime for deferred streams (openclaw#147689) test(qa): compare Telegram entities semantically (openclaw#147752) fix(plugins): preserve runtime scope for deferred CLI actions (openclaw#147688) test(qa): keep Slack progress marker visible (openclaw#147748) test(qa): finish channel picker prompts (openclaw#147730) test(tui): handle auth restriction prompt (openclaw#147729) fix(qa): retain onboarding prompts across redraw bursts (openclaw#147687) ...
* commit '4ddb9ed21245eaca9f243e555a5ec070aaaf0dad': (113 commits) fix: avoid Gateway stalls when renaming sessions (openclaw#147869) refactor(plugins): reuse worker optional-method validation (openclaw#147925) refactor(infra): remove unreachable firewall diagnostic fallback (openclaw#147882) fix(ui): open attached automations from session hovercards (openclaw#147749) refactor(reply): share usage-bar numeric coercion (openclaw#147863) fix(doctor): report warnings for keyed agent configs (openclaw#123058) perf(plugins): reuse complete registry comparisons (openclaw#147893) fix(workboard): await lifecycle sweep completion in tests (openclaw#147950) fix: reduce stalls when browsing large session inventories (openclaw#147911) refactor(onboard): share custom model definition (openclaw#147915) feat(ios): collapse completed chat work above replies (openclaw#148002) fix(voice-call): retain state runtime for deferred streams (openclaw#147689) test(qa): compare Telegram entities semantically (openclaw#147752) fix(plugins): preserve runtime scope for deferred CLI actions (openclaw#147688) test(qa): keep Slack progress marker visible (openclaw#147748) test(qa): finish channel picker prompts (openclaw#147730) test(tui): handle auth restriction prompt (openclaw#147729) fix(qa): retain onboarding prompts across redraw bursts (openclaw#147687) fix(qa): seed Teams ambiguous timeout deterministically (openclaw#147686) refactor(mcp): load OAuth only when credentials are needed (openclaw#147884) ...
* fix: avoid Gateway stalls when renaming sessions * test: preserve historical schemas when adding the label index * test: bound heartbeat polling by lease expiry Use the original persisted expiry as the resume assertion deadline. The default poll timeout equals the worker heartbeat interval, so its final sample can miss a valid renewal before expiry after lifecycle contention. Preserve the exclusion and final ownership assertions. A baseline phase probe reproduced the false failure; the corrected phase and all 16 heartbeat cases pass on base and candidate. * fix: settle plugin startup proof and defer session setup copy * fix: declare the new session translation namespace * test: remove redundant sidebar sorting wrapper * perf: avoid reparsing large plaintext fallbacks * test: share numbered transcript row fixtures
Related: #147837
What Problem This Solves
Renaming sessions can stall other Gateway work when the retained session inventory is large. The label-owner query scans wide session rows, including when the requested label is unused.
User Impact
Session renames spend less time checking whether a label is already in use. Session targeting still uses the key; all three label-authority checks and existing collision behavior are preserved.
The writable schema owner installs a nonunique partial covering index on
(label, session_key)at first open. On a synthetic 3,550-session database, installation and verification added a median 86 ms once and the index occupied 228 KiB. Agent schema remains version 20. Read-only startup accepts an absent index until writable opening; a verified same-version predecessor can read and write the indexed database.Large plaintext replies also render faster after a separate bottleneck surfaced during CI validation. Their fallback now creates text nodes before the existing sanitizer, avoiding an unnecessary escape-and-HTML-parse round trip. Output and sanitizer behavior are preserved.
Why This Change Was Made
Moving ordering out of SQL improved the lookup median by only about 2%. The covering index supplies the existing query without another cache. Interleaved canonical-writer trials measured about 35 microseconds of added work per rename, against three millisecond-scale scans avoided. No canonical data, uniqueness constraint, retention, or permission changes are introduced.
The missing-index exemption checks the entire schema's index namespace. A present index on the wrong table, including a differently cased name, remains a schema error. Independent review identified and verified that validator repair. The accepted schema decision records the lifecycle, rollback behavior, and write/disk tradeoff.
Evidence
On 3,550 synthetic entries containing about 116 MB of canonical JSON, unused-label lookup median fell from 4.170 ms to 0.00359 ms; one-owner lookup fell from 3.473 ms to 0.00538 ms. Focused schema, missing-index repair, drift, preflight, label-claim, and release/reclaim race checks pass. The final conflict-only rebase passed 118 selected schema/index/preflight tests with two existing Node-version-specific skips.
The matched built-Gateway comparison used the same 3,550-session inventory, 64 turns, 512 history reads, 256 label updates, and 32 sampler rounds. All requests, post-profile duplicate-label refusals, keyed renames, and settled-state checks passed.
This is one paired synthetic run, pinned to candidate
65fea01c7bdd594526e1805fae019e1625a184b3. Background model calls differed (567/583); peak loop delay remained 427/416 ms, and history p95 rose from 339 to 364 ms. It demonstrates the rename hotspot improvement, not removal of all Gateway contention or a production latency guarantee.Package and rollback proof
Historical Package Acceptance passed for
65fea01c7bdd594526e1805fae019e1625a184b3, including npm 12 installation and final artifact verification. The published[email protected]updater preserved 4,800 sessions, 23,890 transcript events, 2,200 cron jobs, and 512 plugin-state records. Migration was checked before standalone Doctor; history RPC passed for eight conversations across two agents before and after restart. Tarball SHA-256:4d31f606d8a4370d92c1cc2c219d196d115ed7238125c9b0fe02c62b5a9fff6a.Fresh Package Acceptance passed on workflow attempt 2 for package source
a13f2ee28af4cc8f38820ede3179b81ea1fb0122, including npm 12 installation and final artifact verification. The survivor scenario passed its first execution in 535 seconds, preserving the same session/event/job/plugin counts and eight histories before and after restart. Automatic migration preceded standalone Doctor; idempotent Doctor took 34 seconds and startup took 48 seconds. Its tarball SHA-256 is4e90fe439ed4a31c6493f1a6e423c2db4b9386ab205b9e2d464b355ecfd9211e. The exact package already passed local read-only preflight, writable opening that installed only the label index, and canonical-table/hash preservation. Retained schema-20 runtimecc5a7467f93ed9001bd08419593a27082e9bf029then read, renamed, closed, and reopened pre-index and candidate-produced copies; all 3,549 unrelated sessions and schema metadata remained unchanged.The first hosted attempt stopped at source admission after a conflict rebase removed its pinned package commit from the branch history. Restoring that exact source on a task branch allowed the existing failed-job replay; no admission policy changed. Package evidence retains its original source identity. The index schema, validator, preflight, and label-replacement owners are byte-identical across the rebase; subsequent UI changes are covered separately and are not claimed as part of that tarball.
Validation repairs and current gates
CI exposed inherited fixture problems. Derived v14/v15 schemas now omit the newly current index, preserving both frozen hashes. Heartbeat polling uses the remaining original persisted lease lifetime, preserving ownership/exclusion assertions; a base phase probe demonstrated the former false failure and all 16 selected cases pass. Removing one private sidebar forwarding wrapper fixes its unchanged line limit while retaining all sort transitions. Main independently absorbed the verified plugin-startup settlement repair in #147571, so those files are absent from this PR.
Three unchanged New Session strings now use their existing lazy catalog with synchronous consumer registration and unchanged host catalog order. All 609,127 composed catalog bytes are identical; 54 caller/sibling checks and keyless i18n pass. The explicit namespace type correction emits identical JavaScript. CI on production head
de6cc8dbpassed the unchanged startup budget at 361,715 gzip bytes against 361,938. The subsequent commit is test-only; final-head CI also passed this unchanged gate.The plaintext fallback uses DOMPurify unconditionally with the existing hooks and options on both oversized and parser-error paths. On two ordinary 84–87 KB Node/JSDOM fixtures, render medians fell from 8.54 to 1.29 ms and 9.85 to 1.32 ms. Twelve large/truncated outputs and four parser-error comparisons are byte-identical, including text normalization and role headers. Seven selected benign tests, owner lint, and formatting pass; their six renderer/owner/test source files match the integrated candidate byte for byte. Existing timing thresholds and sanitization assertions are unchanged. Hosted CI on
de6cc8dbthen passed the complete affected UI shard: 391 files and 6,941 tests, with three existing skips, including both formerly failing timing cases.Required CI passed on final head
0beeaa37391f5ea0ee81bdfe3e3e68eaea2a54d8. Complete-candidate P2 review passed at55b6ad72; fresh P2 reviews of the subsequent Markdown repair and transcript fixture consolidation are also clean. Earlier full changed-file checks passed. The integration checkout's first local rerun stopped before tests on missing package links and before types at the checkout-containment guard; an independent local dependency installation fixed both setup issues, and all seven selected tests now pass in the integration checkout. Its changed-file checks now pass, including core-test/UI types, all three dead-export scans, i18n, formatting, targeted lint and guards. All 144 final-head workflow jobs completed without a failure, and the protectedopenclaw/ci-gateis green. Main subsequently added useful transcript geometry assertions in #147612, taking that test above its existing line limit. Sharing six identical private row fixtures preserves every assertion and passes the exact failed-merge lint at 993 lines under the unchanged 1,000-line limit; all 40 controller tests pass. The final commit changes only that test. The superseded wider manual run is not claimed as passing proof: retained failures included SDK-report heap exhaustion, worktree-containment fixtures, and an unreproduced dashboard iframe click.