Repository navigation
fix(migration): admit frozen snapshots within an explicit memory budget - #2172
Merged
Merged
Conversation
Estimate processing-table working sets before reading payloads, reject an oversized snapshot without a digest, and allow an explicit offline budget. Preserve canonical byte sorting and inspect SQLite through a read-only connection before writable journal setup. Document limits and retry behavior. Constraint: Frozen digests, immutable evidence and force projection repair stay compatible; no plaintext spill or inferred memory authority. Scope-risk: The default conservative per-table budget can reject large maintenance inputs; total RSS and legacy inventory remain outside its guarantee. Tested: Linux Python 3.11 pytest snapshot/CLI/evidence/grant/vector/projection suites (89 passed, 88 external-backend skips); full Linux Ty; changed-file pre-commit/Ruff; git diff --check; isolated 8/32/64 MiB snapshot allocation/RSS comparison.
AlexStocks
requested review from
PsiACE,
frostming and
zhanghuidinah
as code owners
October 21, 2026 11:50
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue or RFC does this PR close?
Closes #2156. Refs #2084 (R12).
Rationale for this change
Frozen migration snapshots sort complete canonical JSON rows, including Source payloads. Streaming the database result alone still retains a linear sorting buffer. An offline migration needs to reject an oversized working set before accepting destructive work while preserving the existing evidence digest.
What changes are included in this PR?
--snapshot-budget-mibon migration plan/apply/verify. Initial rejection returnsready: falsewithout a snapshot digest. SQLite apply preflights through a read-only connection before writable opening can change journal mode.Are there any user-facing changes?
Maintenance inputs exceeding the conservative default estimate are rejected. Operators can explicitly raise the budget after measuring available memory on a stopped backup copy. The budget is per processing table, not a total-process RSS hard cap; legacy inventory, embedding, database driver buffers and other maintenance allocations remain outside it. All writers must remain stopped throughout maintenance.
How was this change tested?
pytest tests/builtin/persistence/test_atomic_memory_snapshot.py tests/test_atomic_memory_migration_cli.py tests/e2e/test_atomic_memory_migration_evidence.py tests/e2e/test_atomic_memory_grant_migration.py tests/e2e/test_atomic_memory_migration_vector.py tests/e2e/test_atomic_memory_projection_rebuild.py -q: 89 passed, 88 skipped on Linux/Python 3.11.15.ty check --python /tmp/pc2167-venv --python-version 3.11 --python-platform linux: passed.git diff --check: passed. The native Windows Ty hook was replaced by the complete Linux check because the baseline has POSIX-only typing diagnostics on Windows.--snapshot-budget-mibis unrecognized. GREEN: byte-preservation and explicit larger-budget retry cases pass with the implementation.The first complete run found a test environment setup gap: the dependency-only Linux virtual environment had no installed PowerContext metadata, so 16 Server-startup tests failed with
PackageNotFoundError. Installing the project without changing runtime dependencies resolved that setup error; the complete rerun above passed. The WSL install uses synthetic package version0.0.0because Windows worktree Git paths are not valid Linux Git paths.CPython 3.11.15/Linux, real SQLite, independent subprocess per synthetic random-payload case:
All admitted pairs have byte-identical digests. The 64 MiB rejection estimates 408104188 bytes and returns no digest. This measures predictable admission, not constant-memory sorting or production backend performance.
The golden fixture covers BLOB/NULL/CJK/decomposed Unicode and JSON ordering different from identity ordering. CLI regressions exercise plan/apply/verify with ordinary paths and SQLite file URIs, byte-for-byte database preservation on rejection, and successful explicit larger-budget retry. Fault injection exercises allocation failure/cancellation before initial snapshot acceptance and successful restart without archived or imported partial evidence.
External backend acceptance is left to the real OceanBase/SeekDB CI jobs; local skipped cases do not establish those results.
AI usage statement
Codex was used to implement and review this change and run the reported validation.