Skip to content

fix: prevent large session migrations from stalling - #104737

Merged
steipete merged 2 commits into
mainfrom
codex/session-migration-batched-manifest
Jul 11, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/session-migration-batched-manifest

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #104731
Related: #98236

AI-assisted: Codex

What Problem This Solves

Fixes an issue where operators upgrading a long-lived OpenClaw state directory could experience a prolonged Gateway startup stall when the SQLite session migration encountered many unreferenced legacy JSONL artifacts. The archive operation itself is a same-filesystem rename, but the recovery manifest was fully serialized twice per file and grew after every move.

Why This Change Was Made

The migration now persists the complete bulk move plan once before the first rename, reserves unique archive destinations across the batch, and checkpoints all successful moves once afterward. Recovery manifests are replaced atomically, preserving the existing crash-recovery contract without per-file quadratic write amplification.

User Impact

Large pre-flip session stores migrate with bounded manifest persistence instead of quadratic serialization and disk I/O. Interrupted migrations still retain every source/destination mapping needed by openclaw doctor --session-sqlite restore.

Evidence

  • corepack pnpm test src/commands/doctor-session-sqlite.test.ts — 33/33 passed on Blacksmith Testbox tbx_01kx9kn6jtsb2cwxn7fhj0rmdh (run).
  • Regression creates 67 unreferenced artifacts, including two filenames that normalize to the same archive basename; it proves unique planned destinations, complete planned/completed recovery mappings, atomic replacement, and fewer than 20 manifest checkpoints.
  • env OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 corepack pnpm check:changed — passed format, core and core-test tsgo, core lint, and all selected architecture guards on Testbox tbx_01kx9kndwx88v80ae3ht7200mk (run).
  • .agents/skills/autoreview/scripts/autoreview --mode local --engine codex --model gpt-5.6-sol --thinking high --codex-speed fast — clean after accepting and fixing the archive-path collision finding.

@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Jul 11, 2026
@steipete

steipete commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Land-ready proof for 2730b45f548 (runtime patch 791526b485a; the head-only follow-up removes the release-owned changelog edit required by the prepare gate):

  • corepack pnpm test src/commands/doctor-session-sqlite.test.ts — 33/33 passed on Blacksmith Testbox tbx_01kx9kn6jtsb2cwxn7fhj0rmdh (run).
  • Regression covers bounded bulk manifest checkpoints, atomic replacement, complete planned/completed recovery mappings, and sanitized archive-name collisions.
  • env OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 corepack pnpm check:changed — passed on Testbox tbx_01kx9kndwx88v80ae3ht7200mk (run): format, core/core-test tsgo, core lint, and selected architecture guards.
  • GPT-5.6 Sol/high autoreview: clean after accepting and fixing one archive-path collision finding.

Known proof gap: production-scale live migration will run immediately after landing because deploying the pre-fix migration would risk an extended Gateway outage. The change is covered by focused real-filesystem migration/restore tests and the repository changed gate before that live rollout.

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Jul 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 791526b485

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread CHANGELOG.md Outdated

### Fixes

- **Session SQLite migration scale:** batch recovery-manifest checkpoints for unreferenced JSONL archive moves and replace manifests atomically, preventing large pre-flip stores from incurring quadratic startup I/O while preserving crash recovery. Fixes #104731.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove the normal-fix changelog entry

For this non-release fix commit, the root AGENTS.md Docs / Changelog rule says CHANGELOG.md is release-only and that release generation owns it; normal PRs/direct main fixes should not edit it. Keeping this line makes the unreleased changelog diverge from the generated release-note flow and creates avoidable release conflicts, so this entry should be dropped from the fix commit.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit af175c8 into main Jul 11, 2026
104 checks passed
@steipete
steipete deleted the codex/session-migration-batched-manifest branch July 11, 2026 22:24
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 12, 2026
* fix: scale session SQLite migration manifests

* chore: leave release notes to release workflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: session SQLite migration stalls on large legacy stores

1 participant