diff options
| author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2023-04-26 03:23:14 +0000 |
|---|---|---|
| committer | MongoDB Bot <mongo-bot@mongodb.com> | 2024-04-19 18:52:01 +0000 |
| commit | 74501701e2e7eae72095c959b71f6ebe860943de (patch) | |
| tree | 30f835fbccbc8dc28748c6bf0ab43921a00ed247 | |
| parent | c093484238b8ab1926c00a1f9f01180f5dab5f25 (diff) | |
SERVER-76534 Fix reporting the namespace and UUID in a backup cursor when the changes have not yet been checkpointedr7.0.9-rc1r7.0.9
(cherry picked from commit be9f000e21ff7f97baad57b9ee7c581614089087)
(cherry picked from commit d34d0d6b5b1974394f45faf3187c3560f38a8c3b)
GitOrigin-RevId: 3ff3a3925c36ed277cf5eafca5495f2e3728dd67
| -rw-r--r-- | jstests/hot_backups/backup_restore_metadata.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/jstests/hot_backups/backup_restore_metadata.js b/jstests/hot_backups/backup_restore_metadata.js new file mode 100644 index 00000000000..bfd50f4b791 --- /dev/null +++ b/jstests/hot_backups/backup_restore_metadata.js @@ -0,0 +1,65 @@ +/** + * Tests that the ident metadata is pulled from the catalog using a checkpoint cursor, if it exists. + * Otherwise we fallback to retrieving the ident metadata from the latest catalog as a best guess. + * + * @tags: [ + * requires_persistence, + * requires_replication, + * ] + */ +(function() { +"use strict"; + +const rst = ReplSetTest({ + nodes: 1, + nodeOptions: { + setParameter: + // Control checkpoints. + {"failpoint.pauseCheckpointThread": tojson({mode: "alwaysOn"})} + } +}); +rst.startSet(); +rst.initiate(); + +let primary = rst.getPrimary(); +let primaryDB = primary.getDB("test"); + +// Take the initial checkpoint. +assert.commandWorked(primaryDB.adminCommand({fsync: 1})); + +// Create "a" and ensure it is in the checkpoint. +assert.commandWorked(primaryDB.createCollection("a")); +assert.commandWorked(primaryDB.adminCommand({fsync: 1})); + +// Create "b", which will not be part of the checkpoint used by $backupCursor. +assert.commandWorked(primaryDB.createCollection("b")); + +// Rename "a" to "c". The backup cursor will still report the namespace as "a". +assert.commandWorked(primaryDB.adminCommand({renameCollection: "test.a", to: "test.c"})); + +let namespacesFound = {}; +let backupCursor = primary.getDB("admin").aggregate([{$backupCursor: {}}]); +while (backupCursor.hasNext()) { + let doc = backupCursor.next(); + jsTestLog(doc); + + if (namespacesFound.hasOwnProperty(doc.ns)) { + namespacesFound[doc.ns] += 1; + } else { + namespacesFound[doc.ns] = 1; + } +} + +// Two entries for these namespaces. One for the collection, and one for the _id index. +assert.eq(2, namespacesFound["test.a"]); +assert.eq(2, namespacesFound["test.b"]); + +// The rename was not part of the checkpoint. +assert.eq(undefined, namespacesFound["test.c"]); + +backupCursor.close(); + +assert.commandWorked( + primary.adminCommand({configureFailPoint: "pauseCheckpointThread", mode: "off"})); +rst.stopSet(); +})(); |
