summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2017-02-17 11:33:02 -0500
committerGeert Bosch <geert@mongodb.com>2017-04-28 20:21:51 -0400
commitac9457b4a5235a5f1f257721500dbb89fd6935c1 (patch)
tree2c8a763bf55bdb5326b4b8527553e530c9fbe299
parent4213c76de48f4e5c08009f8f347f817a77593019 (diff)
downloadmongo-ac9457b4a5235a5f1f257721500dbb89fd6935c1.tar.gz
SERVER-28038 Improve invariants in WiredTigerRecordStore for capped visibility
(cherry picked from commit 602a80c2b9745234daebb21dbdd81a456713cf33)
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp13
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h2
2 files changed, 7 insertions, 8 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
index fb254424b5a..6ce589d087a 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
@@ -1281,7 +1281,7 @@ Status WiredTigerRecordStore::_insertRecords(OperationContext* txn,
} else if (_isCapped) {
stdx::lock_guard<stdx::mutex> lk(_uncommittedRecordIdsMutex);
record.id = _nextId();
- _addUncommitedRecordId_inlock(txn, record.id);
+ _addUncommittedRecordId_inlock(txn, record.id);
} else {
record.id = _nextId();
}
@@ -1329,7 +1329,7 @@ StatusWith<RecordId> WiredTigerRecordStore::insertRecord(OperationContext* txn,
}
void WiredTigerRecordStore::_dealtWithCappedId(SortedRecordIds::iterator it, bool didCommit) {
- invariant(&(*it) != NULL);
+ invariant(it->isNormal());
stdx::lock_guard<stdx::mutex> lk(_uncommittedRecordIdsMutex);
if (didCommit && _isOplog && *it != _oplog_highestSeen) {
// Defer removal from _uncommittedRecordIds until it is durable. We don't need to wait for
@@ -1667,7 +1667,7 @@ Status WiredTigerRecordStore::oplogDiskLocRegister(OperationContext* txn, const
return id.getStatus();
stdx::lock_guard<stdx::mutex> lk(_uncommittedRecordIdsMutex);
- _addUncommitedRecordId_inlock(txn, id.getValue());
+ _addUncommittedRecordId_inlock(txn, id.getValue());
return Status::OK();
}
@@ -1746,11 +1746,10 @@ void WiredTigerRecordStore::waitForAllEarlierOplogWritesToBeVisible(OperationCon
});
}
-void WiredTigerRecordStore::_addUncommitedRecordId_inlock(OperationContext* txn,
- const RecordId& id) {
- // todo: make this a dassert at some point
- // invariant(_uncommittedRecordIds.empty() || _uncommittedRecordIds.back() < id);
+void WiredTigerRecordStore::_addUncommittedRecordId_inlock(OperationContext* txn, RecordId id) {
+ dassert(_uncommittedRecordIds.empty() || _uncommittedRecordIds.back() < id);
SortedRecordIds::iterator it = _uncommittedRecordIds.insert(_uncommittedRecordIds.end(), id);
+ invariant(it->isNormal());
txn->recoveryUnit()->registerChange(new CappedInsertChange(this, it));
_oplog_highestSeen = id;
}
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h
index 1997970c9e1..9eac5fec85a 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h
@@ -263,7 +263,7 @@ private:
static RecordId _fromKey(int64_t k);
void _dealtWithCappedId(SortedRecordIds::iterator it, bool didCommit);
- void _addUncommitedRecordId_inlock(OperationContext* txn, const RecordId& id);
+ void _addUncommittedRecordId_inlock(OperationContext* txn, RecordId id);
Status _insertRecords(OperationContext* txn, Record* records, size_t nRecords);