diff options
author | Geert Bosch <geert@mongodb.com> | 2016-09-20 17:08:16 -0400 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2016-09-21 11:39:49 -0400 |
commit | c66a623167c156f953781949deef68b07ee1b9f0 (patch) | |
tree | 0c4c946f957b03ccacfe4ac3b3a096b98a76f5d5 | |
parent | 350f32dbb72909678e9ec4836edb662e1e357f42 (diff) | |
download | mongo-c66a623167c156f953781949deef68b07ee1b9f0.tar.gz |
SERVER-26139 Abandon snapshot after spawning a background index build
Also adds extra logging to help debug similar future issues.
-rw-r--r-- | src/mongo/db/catalog/index_catalog.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/storage/snapshot.h | 4 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp | 6 |
4 files changed, 12 insertions, 3 deletions
diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp index e48040cb591..2315180d796 100644 --- a/src/mongo/db/catalog/index_catalog.cpp +++ b/src/mongo/db/catalog/index_catalog.cpp @@ -405,6 +405,8 @@ void IndexCatalog::IndexBuildBlock::fail() { void IndexCatalog::IndexBuildBlock::success() { Collection* collection = _catalog->_collection; fassert(17207, collection->ok()); + NamespaceString ns(_indexNamespace); + invariant(_txn->lockState()->isDbLockedForMode(ns.db(), MODE_X)); collection->getCatalogEntry()->indexBuildSuccess(_txn, _indexName); @@ -414,6 +416,8 @@ void IndexCatalog::IndexBuildBlock::success() { fassert(17331, entry && entry == _entry); OperationContext* txn = _txn; + LOG(2) << "marking index " << _indexName << " as ready in snapshot id " + << txn->recoveryUnit()->getSnapshotId(); _txn->recoveryUnit()->onCommit([txn, entry, collection] { // Note: this runs after the WUOW commits but before we release our X lock on the // collection. This means that any snapshot created after this must include the full index, diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index 16f655443f0..bac3bc31e95 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -758,6 +758,7 @@ Status applyOperation_inlock(OperationContext* txn, // Wait for thread to start and register itself IndexBuilder::waitForBgIndexStarting(); } + txn->recoveryUnit()->abandonSnapshot(); } else { IndexBuilder builder(indexSpec); Status status = builder.buildInForeground(txn, db); diff --git a/src/mongo/db/storage/snapshot.h b/src/mongo/db/storage/snapshot.h index 6ce5b57e51d..b622c14d863 100644 --- a/src/mongo/db/storage/snapshot.h +++ b/src/mongo/db/storage/snapshot.h @@ -57,6 +57,10 @@ public: return _id != other._id; } + std::string toString() const { + return std::to_string(_id); + } + private: uint64_t _id; }; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp index d02452ff1f0..67ea0f617ff 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp @@ -203,10 +203,10 @@ void WiredTigerRecoveryUnit::_txnClose(bool commit) { WT_SESSION* s = _session->getSession(); if (commit) { invariantWTOK(s->commit_transaction(s, NULL)); - LOG(3) << "WT commit_transaction"; + LOG(3) << "WT commit_transaction for snapshot id " << _mySnapshotId; } else { invariantWTOK(s->rollback_transaction(s, NULL)); - LOG(3) << "WT rollback_transaction"; + LOG(3) << "WT rollback_transaction for snapshot id " << _mySnapshotId; } _active = false; _mySnapshotId = nextSnapshotId.fetchAndAdd(1); @@ -248,7 +248,7 @@ void WiredTigerRecoveryUnit::_txnOpen(OperationContext* opCtx) { invariantWTOK(s->begin_transaction(s, NULL)); } - LOG(3) << "WT begin_transaction"; + LOG(3) << "WT begin_transaction for snapshot id " << _mySnapshotId; _timer.reset(); _active = true; } |