Molt Verify

作者 cockroachdb6c96c6394a61无许可证4 个星标收录于 2026年10月8日更新于 2026年10月8日仓库2个月前更新

Guide for using molt verify to compare source and target databases for schema and row-level consistency after a migration. Use when running verify commands, tuning concurrency/sharding, handling schema mismatches, or validating data integrity post-migration.

仅含说明DevOps & Cloud
AI 生成的概览

指导使用 molt verify 命令,在迁移后检查源数据库与目标数据库的模式和行一致性。

功能
该技能是 molt verify 命令的参考指南,用于在迁移后比较源数据库与目标数据库的模式(DDL)和行级数据一致性。它说明验证阶段、模式、并发与分片选项、各数据源的先决条件、输出报告以及错误恢复。它产出的是命令示例、参数说明和故障排查表格,本身不执行任何操作。
适用场景
适用于运行 molt verify 命令、调整并发或分片、处理模式不匹配,或在迁移后验证数据完整性。它面向迁移后检查,包括仅模式的 CI 门禁以及带过滤或排除列的验证。
运行要求
需要 molt 二进制文件,并能访问源数据库和目标数据库。Oracle 数据源需要 CGO 构建,并将 Oracle Instant Client 放入 LD_LIBRARY_PATH。不包含脚本,仅为说明文档,另附参数参考文档。

molt verify

Compares source and target databases for schema (DDL) and row (data) consistency. Run after molt fetch to confirm migration integrity.

Basic Structure

bash
molt verify \  --source "<source-conn>" \  --target "<crdb-conn>" \  [options]

Verification Phases

Phase 1 — Schema: Compares table presence, columns, types, NOT NULL constraints, and primary key structure.

Phase 2 — Rows (default, --rows=true): Iterates source rows in PK order and compares against target. Reports missing, extraneous, and mismatched rows per shard.

Modes

ModeCommandUse When
Full (default)molt verify --source "..." --target "..."Post-migration integrity check
Schema-onlymolt verify ... --rows=falseFast DDL check; no data I/O

Concurrency & Sharding

bash
# Default: CPU-count tables in parallel, 1 shard/table, 20k rows/batchmolt verify --source "..." --target "..."
# Large tables: parallelize within a single tablemolt verify --source "..." --target "..." \  --concurrency 1 --concurrency-per-table 8 --row-batch-size 50000
# Rate-limited (minimize production impact)molt verify --source "..." --target "..." \  --rows-per-second 1000 --concurrency 2

Sharding splits a table's PK range across workers. Supported PK types: INT, FLOAT, DECIMAL, UUID. Falls back to a single full-scan for unsupported types.

Common Workflows

1. Post-migration sanity check

bash
molt verify \  --source "postgresql://<user>:<password>@pg:5432/db" \  --target "postgresql://root@crdb:26257/db"

2. Schema-only (CI gate)

bash
molt verify \  --source "..." --target "..." \  --rows=false --non-interactive --log-file stdout

3. Filtered verification (subset of tables)

bash
molt verify \  --source "..." --target "..." \  --table-filter "customers|orders"

4. Verify with column exclusions

bash
# transformations.json: {"tables":[{"name":"users","excludedColumns":["temp_col"]}]}molt verify \  --source "..." --target "..." \  --transformations-file transformations.json

Source-Specific Prerequisites

PostgreSQL: No special requirements. Partition tables (child partitions) are not supported — remove them before verifying.

MySQL: Queries current database only. ONLY_FULL_GROUP_BY may affect queries; disable if issues arise.

Oracle: Binary must be built with CGO_ENABLED=1 -tags="cgo source_all". Oracle Instant Client in LD_LIBRARY_PATH. Use --source-cdb for multi-tenant (CDB) setups. Selective data verification (--filter-path) is not supported.

Output & Reporting

Each table prints a summary per shard:

truth rows seen: 10000, success: 9950, missing: 5, mismatch: 45, extraneous: 0
  • missing: rows present on source but absent on target
  • extraneous: rows on target with no match on source
  • mismatch: rows present on both but values differ

Schema issues (missing/extra tables or columns, type mismatches, PK differences) are logged as warnings and do not stop row verification.

Prometheus metrics available at --metrics-listen-addr (default 127.0.0.1:3030).

Error Recovery

ErrorCauseFix
missing table X on targetTable not migratedRerun fetch or check filters
extraneous table X on targetUnexpected tableClean up or adjust --table-filter
column type mismatchType conversion issueCheck type mappings or use --transformations-file
PRIMARY KEY does not matchPK structure differsInspect schema conversion output
partition table XSource has partition tablesDrop/move partitions before verifying
missing a PRIMARY KEYNo PK on source tableAdd PK or use --rows=false
TLSModeDisableErrorInsecure connection rejectedAdd --allow-tls-mode-disable
Statement timeoutQuery exceeds --verify-statement-timeoutIncrease timeout or reduce --row-batch-size

Gotchas

  • Schema changes between source and target after migration are not automatically reconciled — fix schema first, then re-run
  • --concurrency values exceeding 4× CPU count trigger a warning and may degrade performance
  • Row verification requires primary keys on both source and target tables; tables without PKs are skipped for row comparison
  • --filter-path (selective row filters) is not supported for Oracle sources
  • Log files contain sensitive query data; avoid --show-connection-logging in production logs
  • After fetch, always run verify before cutover to confirm data integrity

See flags reference [blocked] for the full flag list.

来源与署名

来源:cockroachdb/claude-plugin位于skills/cockroachdb-onboarding-and-migrations/molt-verify提交6c96c63

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架