VDiff v1
Compare the source and target in a workflow to ensure integrity
Command #
VDiff -- --v1 [--source_cell=<cell>] [--target_cell=<cell>] [--tablet_types=primary,replica,rdonly]
[--limit=<max rows to diff>] [--tables=<table list>] [--format=json] [--max_extra_rows_to_compare=1000]
[--filtered_replication_wait_time=30s] [--debug_query] [--only_pks] <keyspace.workflow>
Description #
VDiff does a row by row comparison of all tables associated with the workflow, diffing the source keyspace and the target keyspace and reporting counts of missing/extra/unmatched rows.
It is highly recommended that you do this before you finalize a workflow with SwitchTraffic
.
Parameters #
--source_cell #
optional
default all
--target_cell #
optional
default all
--tablet_types #
optional
default in_order:RDONLY,REPLICA,PRIMARY
--filtered_replication_wait_time #
optional
default 30s
--limit #
optional
default 9223372036854775807
--tables #
optional
default all tables in the workflow
--format #
optional
default unstructured text output
Example: #
[{
"ProcessedRows": 5,
"MatchingRows": 5,
"MismatchedRows": 0,
"ExtraRowsSource": 0,
"ExtraRowsTarget": 0
},{
"ProcessedRows": 3,
"MatchingRows": 3,
"MismatchedRows": 0,
"ExtraRowsSource": 0,
"ExtraRowsTarget": 0
}]
--max_extra_rows_to_compare #
optional
default 1000
--debug_query #
optional
--only_pks #
optional
keyspace.workflow #
mandatory
Example #
$ vtctlclient VDiff customer.commerce2customer
Summary for corder: {ProcessedRows:10 MatchingRows:10 MismatchedRows:0 ExtraRowsSource:0 ExtraRowsTarget:0}
Summary for customer: {ProcessedRows:11 MatchingRows:11 MismatchedRows:0 ExtraRowsSource:0 ExtraRowsTarget:0}
Using VDiff With Huge Tables #
Currently VDiff runs within vtctld. Each VDiff will stream rows from all sources and targets and then compare them row by row after assembling the rows in order. Since there are no database transactions, VDiff will run much faster than the actual workflow. However, for huge tables (billions of rows or terabytes in size) this can take several hours or even days depending on the number of rows, row composition, server configurations and the topology of the cluster. If your sources and/or targets are across multiple cells, for example, this can slow down the VDiff considerably.
Actual VDiff speeds are of course dependent on several factors in your cluster. But as a reference, we have seen VDiffs run as fast as 400mrph (million rows per hour) (~9B rows/day) for tables with short rows, or as slow as 60mrph (~1.5B rows/day), for tables with larger width and complex columns.
You may need to use one or more of the following recommendations while running long VDiffs:
- If VDiff takes more than an hour
vtctlclient
will hit grpc/http timeouts of 1 hour. In that case you can usevtctl
(the bundledvctlclient
+vtctld
) instead. - VDiff also synchronizes sources and targets to get consistent snapshots. If you have a high write QPS then you may encounter timeouts during the sync. Use higher values of
--filtered_replication_wait_time
to prevent that, for example--filtered_replication_wait_time=4h
. - If VDiff takes more than a day set the
--wait-time
parameter, which is the maximum time a vtctl command can run for, to a value comfortably higher than the expected run time, for example--wait-time=168h
. - You can follow the progress of the command by tailing the vtctld logs. VDiff logs progress every 10 million rows. This can also give you an early indication of how long it will run for, allowing you to increase your settings if needed.
Note #
- There is no throttling, so you might see an increased lag in the replica used as the source.
- VDiff is currently not resumable, so any timeouts or errors mean that you will need to rerun the entire VDiff again.
- VDiff runs one table at a time.