diff options
author | Geert Bosch <geert@mongodb.com> | 2015-05-15 11:45:07 -0400 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2015-05-15 19:57:16 -0400 |
commit | 44018783d2d0476ab7db9708ee98e14a2dd35f4e (patch) | |
tree | 2fe75bfba9865f784f8427f85d3a401972f03814 /src/mongo/db | |
parent | b9a9539e6f39416fc9cc24bdcdc66092d801d52f (diff) | |
download | mongo-44018783d2d0476ab7db9708ee98e14a2dd35f4e.tar.gz |
SERVER-18171: Rename commitAndRestart to abandonSnapshot
Diffstat (limited to 'src/mongo/db')
26 files changed, 42 insertions, 41 deletions
diff --git a/src/mongo/db/catalog/apply_ops.cpp b/src/mongo/db/catalog/apply_ops.cpp index 7f33c477981..9292fbcbf32 100644 --- a/src/mongo/db/catalog/apply_ops.cpp +++ b/src/mongo/db/catalog/apply_ops.cpp @@ -192,7 +192,7 @@ namespace mongo { catch (const WriteConflictException& wce) { LOG(2) << "WriteConflictException while logging applyOps command, retrying."; - txn->recoveryUnit()->commitAndRestart(); + txn->recoveryUnit()->abandonSnapshot(); continue; } } diff --git a/src/mongo/db/catalog/database.cpp b/src/mongo/db/catalog/database.cpp index 0b6a4c1697b..1ac2e3f1c58 100644 --- a/src/mongo/db/catalog/database.cpp +++ b/src/mongo/db/catalog/database.cpp @@ -271,7 +271,7 @@ namespace mongo { catch (const WriteConflictException& exp) { warning() << "could not drop temp collection '" << ns << "' due to " "WriteConflictException"; - txn->recoveryUnit()->commitAndRestart(); + txn->recoveryUnit()->abandonSnapshot(); } } } diff --git a/src/mongo/db/catalog/index_create.cpp b/src/mongo/db/catalog/index_create.cpp index 658978eb1bd..31a32352a11 100644 --- a/src/mongo/db/catalog/index_create.cpp +++ b/src/mongo/db/catalog/index_create.cpp @@ -305,9 +305,9 @@ namespace mongo { wce.logAndBackoff(retries, "index creation", _collection->ns().ns()); // Can't use WRITE_CONFLICT_RETRY_LOOP macros since we need to save/restore exec - // around call to commitAndRestart. + // around call to abandonSnapshot. exec->saveState(); - _txn->recoveryUnit()->commitAndRestart(); + _txn->recoveryUnit()->abandonSnapshot(); exec->restoreState(_txn); // Handles any WCEs internally. } } diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp index 46ad1759247..685cc4ca0ad 100644 --- a/src/mongo/db/commands/create_indexes.cpp +++ b/src/mongo/db/commands/create_indexes.cpp @@ -201,7 +201,7 @@ namespace mongo { // If we're a background index, replace exclusive db lock with an intent lock, so that // other readers and writers can proceed during this phase. if (indexer.getBuildInBackground()) { - txn->recoveryUnit()->commitAndRestart(); + txn->recoveryUnit()->abandonSnapshot(); dbLock.relockWithMode(MODE_IX); if (!repl::getGlobalReplicationCoordinator()->canAcceptWritesForDatabase(dbname)) { return appendCommandStatus(result, Status(ErrorCodes::NotMaster, str::stream() @@ -221,7 +221,7 @@ namespace mongo { try { // This function cannot throw today, but we will preemptively prepare for // that day, to avoid data corruption due to lack of index cleanup. - txn->recoveryUnit()->commitAndRestart(); + txn->recoveryUnit()->abandonSnapshot(); dbLock.relockWithMode(MODE_X); if (!repl::getGlobalReplicationCoordinator()->canAcceptWritesForDatabase( dbname)) { @@ -241,7 +241,7 @@ namespace mongo { } // Need to return db lock back to exclusive, to complete the index build. if (indexer.getBuildInBackground()) { - txn->recoveryUnit()->commitAndRestart(); + txn->recoveryUnit()->abandonSnapshot(); dbLock.relockWithMode(MODE_X); uassert(ErrorCodes::NotMaster, str::stream() << "Not primary while completing index build in " << dbname, diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp index 9b78a2a0543..c4d56be099c 100644 --- a/src/mongo/db/commands/find_cmd.cpp +++ b/src/mongo/db/commands/find_cmd.cpp @@ -333,7 +333,7 @@ namespace mongo { if (!(pq.isTailable() && state == PlanExecutor::IS_EOF)) { // We stash away the RecoveryUnit in the ClientCursor. It's used for // subsequent getMore requests. The calling OpCtx gets a fresh RecoveryUnit. - txn->recoveryUnit()->commitAndRestart(); + txn->recoveryUnit()->abandonSnapshot(); cursor->setOwnedRecoveryUnit(txn->releaseRecoveryUnit()); StorageEngine* engine = getGlobalServiceContext()->getGlobalStorageEngine(); txn->setRecoveryUnit(engine->newRecoveryUnit()); diff --git a/src/mongo/db/commands/pipeline_command.cpp b/src/mongo/db/commands/pipeline_command.cpp index 0763771af70..afc01a8c81a 100644 --- a/src/mongo/db/commands/pipeline_command.cpp +++ b/src/mongo/db/commands/pipeline_command.cpp @@ -137,7 +137,7 @@ namespace mongo { else { // We stash away the RecoveryUnit in the ClientCursor. It's used for subsequent // getMore requests. The calling OpCtx gets a fresh RecoveryUnit. - txn->recoveryUnit()->commitAndRestart(); + txn->recoveryUnit()->abandonSnapshot(); cursor->setOwnedRecoveryUnit(txn->releaseRecoveryUnit()); StorageEngine* storageEngine = getGlobalServiceContext()->getGlobalStorageEngine(); txn->setRecoveryUnit(storageEngine->newRecoveryUnit()); diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp index 3c2750dfb16..13305866af4 100644 --- a/src/mongo/db/commands/write_commands/batch_executor.cpp +++ b/src/mongo/db/commands/write_commands/batch_executor.cpp @@ -874,7 +874,7 @@ namespace mongo { state.unlock(); // This releases any storage engine held locks/snapshots. - _txn->recoveryUnit()->commitAndRestart(); + _txn->recoveryUnit()->abandonSnapshot(); } _txn->checkForInterrupt(); @@ -927,7 +927,7 @@ namespace mongo { finishCurrentOp( _txn, ¤tOp, result.getError() ); // End current transaction and release snapshot. - _txn->recoveryUnit()->commitAndRestart(); + _txn->recoveryUnit()->abandonSnapshot(); if ( result.getError() ) { result.getError()->setIndex( updateItem.getItemIndex() ); @@ -968,7 +968,7 @@ namespace mongo { finishCurrentOp( _txn, ¤tOp, result.getError() ); // End current transaction and release snapshot. - _txn->recoveryUnit()->commitAndRestart(); + _txn->recoveryUnit()->abandonSnapshot(); if ( result.getError() ) { result.getError()->setIndex( removeItem.getItemIndex() ); @@ -1103,7 +1103,7 @@ namespace mongo { catch ( const WriteConflictException& wce ) { state->unlock(); state->txn->getCurOp()->debug().writeConflicts++; - state->txn->recoveryUnit()->commitAndRestart(); + state->txn->recoveryUnit()->abandonSnapshot(); WriteConflictException::logAndBackoff( attempt++, "insert", state->getCollection() ? @@ -1129,7 +1129,7 @@ namespace mongo { // Errors release the write lock, as a matter of policy. if (result->getError()) { - state->txn->recoveryUnit()->commitAndRestart(); + state->txn->recoveryUnit()->abandonSnapshot(); state->unlock(); } } @@ -1366,7 +1366,7 @@ namespace mongo { createCollection = false; // RESTART LOOP fakeLoop = -1; - txn->recoveryUnit()->commitAndRestart(); + txn->recoveryUnit()->abandonSnapshot(); WriteConflictException::logAndBackoff( attempt++, "update", nsString.ns() ); } diff --git a/src/mongo/db/concurrency/write_conflict_exception.h b/src/mongo/db/concurrency/write_conflict_exception.h index ee91721b847..9ebe9c4cb60 100644 --- a/src/mongo/db/concurrency/write_conflict_exception.h +++ b/src/mongo/db/concurrency/write_conflict_exception.h @@ -41,7 +41,7 @@ ++ptxn->getCurOp()->debug().writeConflicts; \ wce.logAndBackoff(wcr__Attempts, (OPSTR), (NSSTR)); \ ++wcr__Attempts; \ - ptxn->recoveryUnit()->commitAndRestart(); \ + ptxn->recoveryUnit()->abandonSnapshot(); \ continue; \ } \ break; \ diff --git a/src/mongo/db/index_builder.cpp b/src/mongo/db/index_builder.cpp index 1d1914712ff..6d71ffb185e 100644 --- a/src/mongo/db/index_builder.cpp +++ b/src/mongo/db/index_builder.cpp @@ -135,7 +135,7 @@ namespace { catch (const WriteConflictException& wce) { LOG(2) << "WriteConflictException while creating collection in IndexBuilder" << ", retrying."; - txn->recoveryUnit()->commitAndRestart(); + txn->recoveryUnit()->abandonSnapshot(); continue; } } @@ -216,7 +216,7 @@ namespace { LOG(2) << "WriteConflictException while creating index in IndexBuilder, retrying."; - txn->recoveryUnit()->commitAndRestart(); + txn->recoveryUnit()->abandonSnapshot(); } } diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index 80d347fe893..ccab80871d4 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -996,7 +996,7 @@ namespace { } catch( const WriteConflictException& e ) { txn->getCurOp()->debug().writeConflicts++; - txn->recoveryUnit()->commitAndRestart(); + txn->recoveryUnit()->abandonSnapshot(); WriteConflictException::logAndBackoff( attempt++, "insert", ns); } } diff --git a/src/mongo/db/operation_context.h b/src/mongo/db/operation_context.h index 9a94d762eed..5c9de5fd52f 100644 --- a/src/mongo/db/operation_context.h +++ b/src/mongo/db/operation_context.h @@ -199,7 +199,7 @@ namespace mongo { /** * RAII-style class to mark the scope of a transaction. ScopedTransactions may be nested. - * An outermost ScopedTransaction calls commitAndRestart() on destruction, so that the storage + * An outermost ScopedTransaction calls abandonSnapshot() on destruction, so that the storage * engine can release resources, such as snapshots or locks, that it may have acquired during * the transaction. Note that any writes are committed in nested WriteUnitOfWork scopes, * so write conflicts cannot happen on completing a ScopedTransaction. @@ -218,7 +218,7 @@ namespace mongo { ~ScopedTransaction() { if (!_txn->lockState()->isLocked()) { - _txn->recoveryUnit()->commitAndRestart(); + _txn->recoveryUnit()->abandonSnapshot(); } } diff --git a/src/mongo/db/query/find.cpp b/src/mongo/db/query/find.cpp index e81b18ea681..cc09944bfc6 100644 --- a/src/mongo/db/query/find.cpp +++ b/src/mongo/db/query/find.cpp @@ -77,7 +77,7 @@ namespace mongo { _txn(txn), _dismissed(false) { // Save this for later. We restore it upon destruction. - _txn->recoveryUnit()->commitAndRestart(); + _txn->recoveryUnit()->abandonSnapshot(); _txnPreviousRecoveryUnit.reset(txn->releaseRecoveryUnit()); // Transfer ownership of the RecoveryUnit from the ClientCursor to the OpCtx. @@ -90,7 +90,7 @@ namespace mongo { } ScopedRecoveryUnitSwapper::~ScopedRecoveryUnitSwapper() { - _txn->recoveryUnit()->commitAndRestart(); + _txn->recoveryUnit()->abandonSnapshot(); if (_dismissed) { // Just clean up the recovery unit which we originally got from the ClientCursor. @@ -706,7 +706,7 @@ namespace mongo { else { // We stash away the RecoveryUnit in the ClientCursor. It's used for subsequent // getMore requests. The calling OpCtx gets a fresh RecoveryUnit. - txn->recoveryUnit()->commitAndRestart(); + txn->recoveryUnit()->abandonSnapshot(); cc->setOwnedRecoveryUnit(txn->releaseRecoveryUnit()); StorageEngine* storageEngine = getGlobalServiceContext()->getGlobalStorageEngine(); txn->setRecoveryUnit(storageEngine->newRecoveryUnit()); diff --git a/src/mongo/db/query/plan_executor.h b/src/mongo/db/query/plan_executor.h index e8c74445787..98fd8991055 100644 --- a/src/mongo/db/query/plan_executor.h +++ b/src/mongo/db/query/plan_executor.h @@ -87,7 +87,7 @@ namespace mongo { YIELD_AUTO, // This will handle WriteConflictExceptions that occur while processing the query, but - // will not yield locks. commitAndRestart() will be called if a WriteConflictException + // will not yield locks. abandonSnapshot() will be called if a WriteConflictException // occurs so callers must be prepared to get a new snapshot. WRITE_CONFLICT_RETRY_ONLY, diff --git a/src/mongo/db/query/plan_yield_policy.cpp b/src/mongo/db/query/plan_yield_policy.cpp index 3f7b8b68287..85cde44cf50 100644 --- a/src/mongo/db/query/plan_yield_policy.cpp +++ b/src/mongo/db/query/plan_yield_policy.cpp @@ -90,7 +90,7 @@ namespace mongo { if (_policy == PlanExecutor::WRITE_CONFLICT_RETRY_ONLY) { // Just reset the snapshot. Leave all LockManager locks alone. - opCtx->recoveryUnit()->commitAndRestart(); + opCtx->recoveryUnit()->abandonSnapshot(); } else { // Release and reacquire locks. diff --git a/src/mongo/db/query/plan_yield_policy.h b/src/mongo/db/query/plan_yield_policy.h index 8342a4adb21..8dc5d45447e 100644 --- a/src/mongo/db/query/plan_yield_policy.h +++ b/src/mongo/db/query/plan_yield_policy.h @@ -40,7 +40,7 @@ namespace mongo { public: /** * If policy == WRITE_CONFLICT_RETRY_ONLY, shouldYield will only return true after - * forceYield has been called, and yield will only commitAndRestart without releasing any + * forceYield has been called, and yield will only abandonSnapshot without releasing any * locks. */ PlanYieldPolicy(PlanExecutor* exec, PlanExecutor::YieldPolicy policy); diff --git a/src/mongo/db/query/query_yield.cpp b/src/mongo/db/query/query_yield.cpp index 9fba99a9ac1..5d6994d7eb6 100644 --- a/src/mongo/db/query/query_yield.cpp +++ b/src/mongo/db/query/query_yield.cpp @@ -60,7 +60,7 @@ namespace mongo { // Top-level locks are freed, release any potential low-level (storage engine-specific // locks). If we are yielding, we are at a safe place to do so. - txn->recoveryUnit()->commitAndRestart(); + txn->recoveryUnit()->abandonSnapshot(); // Track the number of yields in CurOp. txn->getCurOp()->yielded(); diff --git a/src/mongo/db/storage/in_memory/in_memory_recovery_unit.h b/src/mongo/db/storage/in_memory/in_memory_recovery_unit.h index 5b0f5b72940..384691e0f7b 100644 --- a/src/mongo/db/storage/in_memory/in_memory_recovery_unit.h +++ b/src/mongo/db/storage/in_memory/in_memory_recovery_unit.h @@ -53,7 +53,7 @@ namespace mongo { return true; } - virtual void commitAndRestart() {} + virtual void abandonSnapshot() {} virtual void registerChange(Change* change) { _changes.push_back(ChangePtr(change)); diff --git a/src/mongo/db/storage/kv/kv_storage_engine.cpp b/src/mongo/db/storage/kv/kv_storage_engine.cpp index 7ff8221d999..27e2e567ec2 100644 --- a/src/mongo/db/storage/kv/kv_storage_engine.cpp +++ b/src/mongo/db/storage/kv/kv_storage_engine.cpp @@ -131,7 +131,7 @@ namespace mongo { uow.commit(); } - opCtx.recoveryUnit()->commitAndRestart(); + opCtx.recoveryUnit()->abandonSnapshot(); // now clean up orphaned idents diff --git a/src/mongo/db/storage/mmap_v1/dur_recovery_unit.cpp b/src/mongo/db/storage/mmap_v1/dur_recovery_unit.cpp index 078b3e80137..56d68556a42 100644 --- a/src/mongo/db/storage/mmap_v1/dur_recovery_unit.cpp +++ b/src/mongo/db/storage/mmap_v1/dur_recovery_unit.cpp @@ -93,7 +93,7 @@ namespace mongo { _startOfUncommittedChangesForLevel.pop_back(); } - void DurRecoveryUnit::commitAndRestart() { + void DurRecoveryUnit::abandonSnapshot() { invariant( !inAUnitOfWork() ); // no-op since we have no transaction } diff --git a/src/mongo/db/storage/mmap_v1/dur_recovery_unit.h b/src/mongo/db/storage/mmap_v1/dur_recovery_unit.h index be54f9b76b9..4fea7baee59 100644 --- a/src/mongo/db/storage/mmap_v1/dur_recovery_unit.h +++ b/src/mongo/db/storage/mmap_v1/dur_recovery_unit.h @@ -54,7 +54,7 @@ namespace mongo { virtual bool awaitCommit(); - virtual void commitAndRestart(); + virtual void abandonSnapshot(); // The recovery unit takes ownership of change. virtual void registerChange(Change* change); diff --git a/src/mongo/db/storage/mmap_v1/heap_record_store_btree.h b/src/mongo/db/storage/mmap_v1/heap_record_store_btree.h index 0ad28bc1d03..38ea46dc742 100644 --- a/src/mongo/db/storage/mmap_v1/heap_record_store_btree.h +++ b/src/mongo/db/storage/mmap_v1/heap_record_store_btree.h @@ -189,7 +189,7 @@ namespace mongo { virtual bool awaitCommit() { return true; } - virtual void commitAndRestart() {} + virtual void abandonSnapshot() {} virtual void registerChange(Change* change) { change->commit(); diff --git a/src/mongo/db/storage/recovery_unit.h b/src/mongo/db/storage/recovery_unit.h index c5481225c17..b4a2ba4832f 100644 --- a/src/mongo/db/storage/recovery_unit.h +++ b/src/mongo/db/storage/recovery_unit.h @@ -95,10 +95,11 @@ namespace mongo { virtual void goingToAwaitCommit() { } /** - * When this is called, if there is an open transaction, it is commited and a new one is - * started. This cannot be called inside of a WriteUnitOfWork, and should fail if it is. + * When this is called, if there is an open transaction, it is closed. On return no + * transaction is active. This cannot be called inside of a WriteUnitOfWork, and should + * fail if it is. */ - virtual void commitAndRestart() = 0; + virtual void abandonSnapshot() = 0; virtual SnapshotId getSnapshotId() const = 0; diff --git a/src/mongo/db/storage/recovery_unit_noop.h b/src/mongo/db/storage/recovery_unit_noop.h index 72556fc33aa..79a47b66ea4 100644 --- a/src/mongo/db/storage/recovery_unit_noop.h +++ b/src/mongo/db/storage/recovery_unit_noop.h @@ -41,7 +41,7 @@ namespace mongo { virtual void commitUnitOfWork() {} virtual void endUnitOfWork() {} - virtual void commitAndRestart() {} + virtual void abandonSnapshot() {} virtual bool awaitCommit() { return true; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp index d8f8d6cc016..5239c9d24f8 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp @@ -726,7 +726,7 @@ namespace { it->getNext(); ASSERT_FALSE(it->isEOF()); it->saveState(); - cursorCtx->recoveryUnit()->commitAndRestart(); + cursorCtx->recoveryUnit()->abandonSnapshot(); { // insert 100 documents which causes rollover scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); @@ -881,7 +881,7 @@ namespace { // See that things work if you yield before you first call getNext(). it->saveState(); - cursorCtx->recoveryUnit()->commitAndRestart(); + cursorCtx->recoveryUnit()->abandonSnapshot(); ASSERT_TRUE(it->restoreState(cursorCtx.get())); ASSERT_EQ(loc1, it->getNext()); ASSERT_TRUE(it->isEOF()); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp index c30362d1b1f..f667711d87f 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp @@ -213,7 +213,7 @@ namespace mongo { return _session; } - void WiredTigerRecoveryUnit::commitAndRestart() { + void WiredTigerRecoveryUnit::abandonSnapshot() { invariant(_depth == 0); if (_active) { // Can't be in a WriteUnitOfWork, so safe to rollback diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h index f0142b46f36..dcc4d03168f 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h @@ -71,7 +71,7 @@ namespace mongo { virtual void beingReleasedFromOperationContext(); virtual void beingSetOnOperationContext(); - virtual void commitAndRestart(); + virtual void abandonSnapshot(); // un-used API virtual void* writingPtr(void* data, size_t len) { invariant(!"don't call writingPtr"); } |