From ef141348302249c28c0dd73b66c3f0f8dc91ce89 Mon Sep 17 00:00:00 2001 From: gmiller-mdb <135852653+gmiller-mdb@users.noreply.github.com> Date: Mon, 3 Mar 2025 13:34:47 -0500 Subject: [PATCH] DOCSP-46301-clean-verify-data (#617) * DOCSP-46301-clean-verify-data * move code * fix indent errors * changing table * fix links * feedback * build errors --- source/reference/verification.txt | 68 ++------------- .../reference/verification/custom-manual.txt | 84 +++++++++++++++++++ 2 files changed, 91 insertions(+), 61 deletions(-) create mode 100644 source/reference/verification/custom-manual.txt diff --git a/source/reference/verification.txt b/source/reference/verification.txt index a8895db47..fc18f066e 100644 --- a/source/reference/verification.txt +++ b/source/reference/verification.txt @@ -92,73 +92,18 @@ source to the destination cluster. 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. - - * - .. _c2c-index-comparison: - - Index Comparison - - To verify the transfer of indexes, run the - :method:`db.collection.getIndexes` method on the source - and destination clusters and compare the results. - - * - .. _c2c-metadata-comparison: - - Metadata Comparison - - To verify the transfer of metadata, run the - :method:`db.getCollectionInfos` method on the source and - destination clusters and compare the results. - - * - .. _c2c-shardkey-comparison: - - Shard Key Comparison - - To verify the transfer of shard keys to a synced collection, run a query on the ``config.collections`` - collection to find a document whose ``_id`` value is the namespace of the target collection. - Compare the ``key`` value of this document in the source and destination clusters. - - For example, for a collection named ``pets`` in the ``records`` database, you can verify the shard key - using the following query in :binary:`mongosh`: - - .. io-code-block:: - :copyable: true - - .. input:: - :language: javascript - - db.getSiblingDB("config").collections.find({ _id : "records.pets" }) - - .. output:: - :language: javascript - :emphasize-lines: 5-7 - :visible: false - - { - "_id" : "records.pets", - "lastmod" : ISODate("2021-07-21T15:48:15.193Z"), - "timestamp": Timestamp(1626882495, 1), - "key" : { - "_id" : 1 - }, - "unique" : false, - "lastmodEpoch" : ObjectId("5078407bd58b175c5c225fdc"), - "uuid" : UUID("f8669e52-5c1b-4ea2-bbdc-a00189b341da") - } - * - :ref:`Migration Verifier ` - 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. + * - :ref:`Verifying Data with Custom Scripts ` + - Different types of data require different methods of verification. You can + can use custom or manual verification to verify :ref:`documents `, + :ref:`indexes `, :ref:`metadata `, + and :ref:`shard keys `. + The specific method you use to verify your data depends on your application workload and the complexity of the data. @@ -169,6 +114,7 @@ application workload and the complexity of the data. Use Document Counts Use Hash Comparison Use Migration Verifier + Verifying Data with Custom Scripts Learn More ---------- diff --git a/source/reference/verification/custom-manual.txt b/source/reference/verification/custom-manual.txt new file mode 100644 index 000000000..97be7d168 --- /dev/null +++ b/source/reference/verification/custom-manual.txt @@ -0,0 +1,84 @@ +.. _c2c-custom-manual-verification: + +================================== +Verifying Data with Custom Scripts +================================== + +.. default-domain:: mongodb + +.. facet:: + :name: genre + :values: tutorial + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +You can write a script to query your source cluster and compare the documents, +indexes, collections, metadata, and views with the destination cluster. + +.. _c2c-document-comparison: + +Comparing Documents +------------------- + +You can verify sync by comparing documents on the source and destination clusters. + +Before you can verify data transfer with this method, ``mongosync`` must be in +the ``COMMITTED`` state. + +.. _c2c-index-comparison: + +Comparing Indexes +----------------- + +To verify the transfer of indexes, run :method:`db.collection.getIndexes` +on the source and destination clusters and compare the results. + +.. _c2c-metadata-comparison: + +Comparing Metadata +------------------ + +To verify the transfer of metadata, run :method:`db.getCollectionInfos` +on the source and destination clusters and compare the results. + +.. _c2c-shardkey-comparison: + +Comparing Shard Keys +-------------------- + +To verify the transfer of shard keys to a synced collection, run a query on the +``config.collections`` collection to find a document whose ``_id`` value is the +namespace of the target collection. Compare the ``key`` value of this document +in the source and destination clusters. + +For example, for a collection named ``pets`` in the ``records`` database, you +can verify the shard key using the following query in :binary:`mongosh`: + +.. io-code-block:: + :copyable: true + + .. input:: + :language: javascript + + db.getSiblingDB("config").collections.find({ _id : "records.pets" }) + + .. output:: + :language: javascript + :emphasize-lines: 5-7 + :visible: false + + { + "_id" : "records.pets", + "lastmod" : ISODate("2021-07-21T15:48:15.193Z"), + "timestamp": Timestamp(1626882495, 1), + "key" : { + "_id" : 1 + }, + "unique" : false, + "lastmodEpoch" : ObjectId("5078407bd58b175c5c225fdc"), + "uuid" : UUID("f8669e52-5c1b-4ea2-bbdc-a00189b341da") + } \ No newline at end of file