Skip to content

fix(cli): prove migration verify read the source, not only the manifest (#1306) - #1387

Merged
chappie-daemon merged 5 commits into
rewrite/mainfrom
factory/047-migration-verify
Dec 4, 2026
Merged

chappie-daemon merged 5 commits into
rewrite/mainfrom
factory/047-migration-verify

Conversation

@chappie-daemon

Copy link
Copy Markdown
Collaborator

Issue: #1306 (closed by hand with the merge sha after merge).

The gap

The migration's verify pass proved the store matched the manifest it wrote, not the source. The manifest's rows and checksum were folded from the same batches the store received, and a table counted as complete on count < batch_size — so a source that ended a page early produced copy exit 0, a manifest recording the short total as complete, and verify exit 0. Demonstrated in recon with a 3-row source whose first page answers 1: {"complete":true,"rows":1}, Verified 9 tables, 1 rows.

The fix

  • MigrationSource::count_rows — one SELECT count(*) per table on the master pool the copy already uses; the tool stays read-only against the source and --verify still needs no Postgres.
  • The manifest records source_rows per table and moves to format: 2; a format-1 manifest is refused with … this tool reads and writes 2 (#[serde(default)] so an old file reaches that refusal rather than a serde error).
  • verify_with asserts target rows == entry.rows == entry.source_rows, refuses a short read with [<table>] source {n} rows, target {m} rows, and the success line now says what it proves: Verified 9 tables, {total} rows: the store matches the manifest, and the copy read every source row.
  • ADR 0013 D4 states what the checksum proves (the target) and what the count proves (the copy read the whole table), and names the residual risk: a source mutating between the count and its pages — a delete+insert leaving the total unchanged still passes, which is why D9 requires the source's relay stopped.

Evidence

Oracle cargo test -p nostream-cli --test migrate_cli -- short_page: running 0 tests before, 1 passed now, with the old shape copied to a scratch tree and shown to verify clean. Three new cases (short page, old manifest, failing source count), the accepted format-1 fixtures migrated, nine command criteria inverted and restored, migrate_cli 49 passed.

@changeset-bot

changeset-bot Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f62ed09

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5b6108fe-3c9c-4d6f-9169-864426f9a6dd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@greptile-apps

greptile-apps Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge, with the previously reported help-text issue remaining non-blocking.

Findings

  1. P2 Copy help claims read-only behavior ▶

Summary

The PR records each source table's row count and checks it during verification.

  • Migration verification checks the copied row count against the source count.
  • Migration manifests now use format 2 and require a fresh target when resuming old runs.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  P[Postgres count] --> M[Manifest source_rows]
  B[Source batches] --> L[LMDB store]
  B --> C[Manifest rows and checksum]
  L --> V[Verify]
  M --> V
  C --> V
  V --> R[Require matching counts and checksum]
Loading

Reviews (2) · Last reviewed commit: "docs: correct what verify proves and the..." · Reviewed by Greptile

Comment on lines +699 to +700
///
/// It reads the store only and proves the copy read every source row the counts recorded

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Copy help claims read-only behavior

This paragraph belongs to PgToLmdb, so the copy command's help now says “It reads the store only.” The copy actually reads Postgres and writes LMDB. Move this explanation to verify and finish the sentence, which currently ends at “recorded.” Otherwise operators get the wrong description of what the command changes.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Dec 4, 2026
@chappie-daemon
chappie-daemon force-pushed the factory/047-migration-verify branch from a16d5e9 to f62ed09 Compare December 4, 2026 15:41
@greptile-apps
greptile-apps Bot dismissed their stale review December 4, 2026 15:41

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@chappie-daemon
chappie-daemon merged commit 0238ed6 into rewrite/main Dec 4, 2026
17 checks passed
@chappie-daemon
chappie-daemon deleted the factory/047-migration-verify branch December 4, 2026 15:53
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