summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Williams <louis.williams@mongodb.com>2019-10-01 18:16:39 +0000
committerevergreen <evergreen@mongodb.com>2019-10-01 18:16:39 +0000
commit98939f35ef1f58566b20ac5e78debb42a56b0366 (patch)
treec578bd46e9beea716b9ba4a90f2fb4463a5d5976
parent085fc94cf3333a66544d3a632c77f5a7e889579b (diff)
downloadmongo-98939f35ef1f58566b20ac5e78debb42a56b0366.tar.gz
SERVER-43727 Yield locks on secondaries while waiting for two-phase index builds to commit or abort
-rw-r--r--jstests/noPassthrough/auth_reject_mismatching_logical_times.js1
-rw-r--r--jstests/noPassthrough/backup_restore_fsync_lock.js1
-rw-r--r--jstests/noPassthrough/backup_restore_rolling.js1
-rw-r--r--jstests/noPassthrough/backup_restore_stop_start.js1
-rw-r--r--jstests/noPassthrough/comment_field_passthrough.js1
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp12
6 files changed, 12 insertions, 5 deletions
diff --git a/jstests/noPassthrough/auth_reject_mismatching_logical_times.js b/jstests/noPassthrough/auth_reject_mismatching_logical_times.js
index 6fdf4a17a44..13b971c7bc5 100644
--- a/jstests/noPassthrough/auth_reject_mismatching_logical_times.js
+++ b/jstests/noPassthrough/auth_reject_mismatching_logical_times.js
@@ -4,7 +4,6 @@
* @tags: [
* requires_replication,
* requires_sharding,
- * two_phase_index_builds_unsupported,
* ]
*/
(function() {
diff --git a/jstests/noPassthrough/backup_restore_fsync_lock.js b/jstests/noPassthrough/backup_restore_fsync_lock.js
index 2f0eeab6f84..f6f720377aa 100644
--- a/jstests/noPassthrough/backup_restore_fsync_lock.js
+++ b/jstests/noPassthrough/backup_restore_fsync_lock.js
@@ -14,7 +14,6 @@
* @tags: [
* requires_persistence,
* requires_replication,
- * two_phase_index_builds_unsupported,
* ]
*/
diff --git a/jstests/noPassthrough/backup_restore_rolling.js b/jstests/noPassthrough/backup_restore_rolling.js
index e6ac0e69188..63f6b1a7cd2 100644
--- a/jstests/noPassthrough/backup_restore_rolling.js
+++ b/jstests/noPassthrough/backup_restore_rolling.js
@@ -14,7 +14,6 @@
* @tags: [
* requires_persistence,
* requires_wiredtiger,
- * two_phase_index_builds_unsupported,
* ]
*/
diff --git a/jstests/noPassthrough/backup_restore_stop_start.js b/jstests/noPassthrough/backup_restore_stop_start.js
index 8ef9e9e30e1..2598b8670ab 100644
--- a/jstests/noPassthrough/backup_restore_stop_start.js
+++ b/jstests/noPassthrough/backup_restore_stop_start.js
@@ -14,7 +14,6 @@
* @tags: [
* requires_persistence,
* requires_replication,
- * two_phase_index_builds_unsupported,
* ]
*/
diff --git a/jstests/noPassthrough/comment_field_passthrough.js b/jstests/noPassthrough/comment_field_passthrough.js
index 13fe13b4cbf..6e00d61f360 100644
--- a/jstests/noPassthrough/comment_field_passthrough.js
+++ b/jstests/noPassthrough/comment_field_passthrough.js
@@ -7,7 +7,6 @@
* requires_replication,
* requires_sharding,
* requires_wiredtiger,
- * two_phase_index_builds_unsupported,
* ]
*/
(function() {
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index 964ddc13942..6b7c49a9a6a 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -1015,6 +1015,18 @@ void IndexBuildsCoordinator::_buildIndex(
if (supportsTwoPhaseIndexBuild() && indexBuildOptions.replSetAndNotPrimary &&
IndexBuildProtocol::kTwoPhase == replState->protocol) {
+
+ log() << "Index build waiting for commit or abort before completing final phase: "
+ << replState->buildUUID;
+
+ // Yield locks and storage engine resources before blocking.
+ opCtx->recoveryUnit()->abandonSnapshot();
+ Lock::TempRelease release(opCtx->lockState());
+ invariant(!opCtx->lockState()->isLocked(),
+ str::stream()
+ << "failed to yield locks for index build while waiting for commit or abort: "
+ << replState->buildUUID);
+
stdx::unique_lock<Latch> lk(replState->mutex);
auto isReadyToCommitOrAbort = [rs = replState] { return rs->isCommitReady || rs->aborted; };
opCtx->waitForConditionOrInterrupt(replState->condVar, lk, isReadyToCommitOrAbort);