Docs Menu
Docs Home
/
MongoDB Cluster-to-Cluster Sync
/

Verify Data Transfer

On this page

  • Tasks
  • Learn More

Before you switch your application load from the source cluster to the destination cluster, you should verify that the migration was successful.

Starting in 1.9, mongosync provides an embedded verifier that can perform a series of verification checks on the source and destination cluster to confirm the sync was successful.

You should verify your data after every sync. This is important in cases where you plan to move your application load from the source to the destination cluster.

Verification Method
Description
Embedded Verifier

Starting in 1.9, mongosync includes an embedded verifier, which runs a series of verification checks on the source and destination clusters to confirm that the migration was successful. This is the preferred verification method for deployments that meet the requirements.

When the mongosync process starts, it prompts the user with a disclaimer about the embedded verifier. You must accept the disclaimer, or if you have already read and acknowledged it, start mongosync with the --acceptDisclaimer option to use the verifier.

The verifier doesn't check every aspect of a migration:

  • To verify sync on unsupported namespaces and sharded clusters, use a different verification method.

  • To verify index sync, use the Index Comparison method.

  • To verify metdata sync, use the Metadata Comparison method.

The most basic method of verification is to compare the number of documents in each synced collection on the source cluster to the number on the destination cluster.

Before you can verify data transfer with this method, mongosync must be in the COMMITTED state.

This method only verifies a successful sync when run against clusters with insert-only workloads.

You can verify sync by comparing MD5 hashes of collections synced from the source cluster to the destination cluster.

Before you can verify data transfer with this method, mongosync must be in the COMMITTED state.

While hash comparison ensures that the destination cluster has received all changes from the source, the dbHash command locks the cluster, preventing additional writes until it completes.

Hash comparison is not possible with sharded clusters. It also does not work with standalone servers and replica sets that use MongoDB 4.4 or earlier releases, since the document field order can vary.

Document Comparison

You can verify sync by comparing documents on the source and destination clusters.

Write a script that queries collections on the source cluster and then checks that the correct documents, indexes, collections, metadata, and views exist with the same values on the destination cluster.

Before you can verify data transfer with this method, mongosync must be in the COMMITTED state.

Index Comparison

To verify the transfer of indexes, run the db.collection.getIndexes() method on the source and destination clusters and compare the results.

Metadata Comparison

To verify the transfer of metadata, run the db.getCollectionInfos() method on the source and destination clusters and compare the results.

Migration Verifier connects to the source and destination clusters and performs a series of verification checks, comparing documents, views, and indexes to confirm the sync was successful.

Migration Verifier is an experimental and unsupported tool.

The specific method you use to verify your data depends on your application workload and the complexity of the data.

Back

Telemetry

On this page