diff options
-rw-r--r-- | jstests/hooks/run_check_repl_dbhash_background.js | 6 | ||||
-rw-r--r-- | src/mongo/db/commands/dbhash.cpp | 7 |
2 files changed, 13 insertions, 0 deletions
diff --git a/jstests/hooks/run_check_repl_dbhash_background.js b/jstests/hooks/run_check_repl_dbhash_background.js index 1a61b3c2785..a6257cdbefb 100644 --- a/jstests/hooks/run_check_repl_dbhash_background.js +++ b/jstests/hooks/run_check_repl_dbhash_background.js @@ -291,6 +291,12 @@ function checkReplDbhashBackgroundThread(hosts) { hasTransientError = true; } + // dbHash has a lock deadline to bound the amount of time it can conflict with other + // operations. + if (e.code == ErrorCodes.LockTimeout) { + hasTransientError = true; + } + // Perform a no-op write to the primary if the clusterTime between each call remain // the same and if we encounter the SnapshotUnavailable error as the secondaries // minimum timestamp can be greater than the primaries minimum timestamp. diff --git a/src/mongo/db/commands/dbhash.cpp b/src/mongo/db/commands/dbhash.cpp index fe734f964fe..eceed0ed4e9 100644 --- a/src/mongo/db/commands/dbhash.cpp +++ b/src/mongo/db/commands/dbhash.cpp @@ -202,6 +202,13 @@ public: // none of the collections get dropped. lockMode = LockMode::MODE_IS; + // We will hold open a snapshot at a timestamp for a long period of time while waiting + // for collection locks. This has the potential to deadlock with an index build that has + // just failed and is trying to write using the same timestamp we are using to read. + // Impose a generous maximum timeout to force dbHash to time out and allow the index + // build to make progress. See SERVER-53376. + opCtx->lockState()->setMaxLockTimeout(duration_cast<Milliseconds>(Seconds(30))); + // Additionally, if we are performing a read at a timestamp, then we allow oplog // application to proceed concurrently with the dbHash command. This is done // to ensure a prepare conflict is able to eventually be resolved by processing a |