summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2014-12-16 11:49:30 -0500
committerEliot Horowitz <eliot@10gen.com>2014-12-16 12:14:13 -0500
commitd061b19c0bfc48a5a7e16d328919945f952c3e9f (patch)
tree3841ecd561219c26389bbeebbf08ebf901d15d5c /src
parent50745fafe0084ae35f68b69aff62e3ef5895fc30 (diff)
downloadmongo-d061b19c0bfc48a5a7e16d328919945f952c3e9f.tar.gz
SERVER-16519 SERVER-16235: WT capped conflict fix and stop special casing oplog
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp51
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h3
2 files changed, 22 insertions, 32 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
index e95cb4a6009..ad5906895bc 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
@@ -356,17 +356,15 @@ namespace {
return false;
}
-namespace {
- int oplogCounter = 0;
-}
-
void WiredTigerRecordStore::cappedDeleteAsNeeded(OperationContext* txn,
const RecordId& justInserted ) {
- if ( _isOplog ) {
- if ( oplogCounter++ % 100 > 0 )
- return;
- }
+ // We only want to do the checks occasionally as they are expensive.
+ // This variable isn't thread safe, but has loose semantics anyway.
+ dassert( !_isOplog || _cappedMaxDocs == -1 );
+ if ( _cappedMaxDocs == -1 && // Max docs has to be exact, so have to check every time.
+ _cappedDeleteCheckCount++ % 100 > 0 )
+ return;
if (!cappedAndNeedDelete())
return;
@@ -376,14 +374,12 @@ namespace {
if ( !lock )
return;
- WiredTigerRecoveryUnit* realRecoveryUnit = NULL;
- if ( _isOplog ) {
- // we do this is a sub transaction in case it aborts
- realRecoveryUnit = dynamic_cast<WiredTigerRecoveryUnit*>( txn->releaseRecoveryUnit() );
- invariant( realRecoveryUnit );
- WiredTigerSessionCache* sc = realRecoveryUnit->getSessionCache();
- txn->setRecoveryUnit( new WiredTigerRecoveryUnit( sc ) );
- }
+ // we do this is a sub transaction in case it aborts
+ WiredTigerRecoveryUnit* realRecoveryUnit =
+ dynamic_cast<WiredTigerRecoveryUnit*>( txn->releaseRecoveryUnit() );
+ invariant( realRecoveryUnit );
+ WiredTigerSessionCache* sc = realRecoveryUnit->getSessionCache();
+ txn->setRecoveryUnit( new WiredTigerRecoveryUnit( sc ) );
try {
WiredTigerCursor curwrap( _uri, _instanceId, txn);
@@ -418,26 +414,19 @@ namespace {
}
catch ( const WriteConflictException& wce ) {
- if ( _isOplog ) {
- delete txn->releaseRecoveryUnit();
- txn->setRecoveryUnit( realRecoveryUnit );
- log() << "got conflict purging oplog, ignoring";
- return;
- }
- throw;
+ delete txn->releaseRecoveryUnit();
+ txn->setRecoveryUnit( realRecoveryUnit );
+ log() << "got conflict truncating capped, ignoring";
+ return;
}
catch ( ... ) {
- if ( _isOplog ) {
- delete txn->releaseRecoveryUnit();
- txn->setRecoveryUnit( realRecoveryUnit );
- }
- throw;
- }
-
- if ( _isOplog ) {
delete txn->releaseRecoveryUnit();
txn->setRecoveryUnit( realRecoveryUnit );
+ throw;
}
+
+ delete txn->releaseRecoveryUnit();
+ txn->setRecoveryUnit( realRecoveryUnit );
}
StatusWith<RecordId> WiredTigerRecordStore::extractAndCheckLocForOplog(const char* data,
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h
index 33e4b8c4849..0011fffabc7 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h
@@ -250,7 +250,8 @@ namespace mongo {
const int64_t _cappedMaxSize;
const int64_t _cappedMaxDocs;
CappedDocumentDeleteCallback* _cappedDeleteCallback;
- boost::mutex _cappedDeleterMutex; // see commend in ::cappedDeleteAsNeeded
+ int _cappedDeleteCheckCount; // see comment in ::cappedDeleteAsNeeded
+ boost::mutex _cappedDeleterMutex; // see comment in ::cappedDeleteAsNeeded
const bool _useOplogHack;