Use replication-only
mode to resume replication to CockroachDB after an interruption, without reloading data.
These steps assume that you previously started replication. Refer to Load and Replicate or Load and Replicate Separately.
Resume replication after interruption
In the molt fetch
command, use --replicator-flags
to pass options to the included replicator
process that handles continuous replication. For details on all available flags, refer to the MOLT Fetch documentation.
Flag | Description |
---|---|
--stagingSchema |
Required. Staging schema name for the changefeed checkpoint table. |
--metricsAddr |
Enable Prometheus metrics at a specified {host}:{port} . Metrics are served at http://{host}:{port}/_/varz . |
Resuming replication requires --stagingSchema
, which specifies the staging schema name used as a checkpoint. MOLT Fetch logs the staging schema name when it starts replication:
staging database name: _replicator_1749699789613149000
When using --table-filter
, you must also include --userscript
. Refer to Table filter userscript.
When using --table-filter
, you must also include --userscript
. Refer to Table filter userscript.
Issue the MOLT Fetch command to start replication on CockroachDB, specifying
--mode replication-only
.Be sure to specify the same
--pglogical-replication-slot-name
value that you provided on data load.molt fetch \ --source $SOURCE \ --target $TARGET \ --table-filter 'employees|payments|orders' \ --pglogical-replication-slot-name cdc_slot \ --replicator-flags '--stagingSchema _replicator_1749699789613149000 --metricsAddr :30005' \ --mode replication-only
molt fetch \ --source $SOURCE \ --target $TARGET \ --table-filter 'employees|payments|orders' \ --non-interactive \ --replicator-flags '--stagingSchema _replicator_1749699789613149000 --metricsAddr :30005 --userscript table_filter.ts' \ --mode replication-only
molt fetch \ --source $SOURCE \ --source-cdb $SOURCE_CDB \ --target $TARGET \ --schema-filter 'migration_schema' \ --table-filter 'employees|payments|orders' \ --replicator-flags '--stagingSchema _replicator_1749699789613149000 --metricsAddr :30005 --userscript table_filter.ts' \ --mode 'replication-only'
Replication resumes from the last checkpoint without performing a fresh load.
Check the output to observe
replicator
progress.A
starting replicator
message indicates that the task has started:{"level":"info","time":"2025-02-10T14:28:13-05:00","message":"starting replicator"}
The
staging database name
message contains the name of the staging schema. The schema name contains a replication marker for streaming changes, which is used for resuming replication, or performing failback to the source database.{"level":"info","time":"2025-02-10T14:28:13-05:00","message":"staging database name: _replicator_1739215693817700000"}
upserted rows
log messages indicate that changes were replicated to CockroachDB:DEBUG [Jan 22 13:52:40] upserted rows conflicts=0 duration=7.620208ms proposed=1 target="\"molt\".\"migration_schema\".\"employees\"" upserted=1