summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2020-06-22 09:34:20 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-13 19:38:41 +0000
commit37dee01bca27a957c5bef67121fe8dc93a6554c1 (patch)
treead14668afc22c832aa42995c10ad18ba6b890d33
parent445ae8fab6ac0ec5e02d94d5afddb1b6827965df (diff)
downloadmongo-37dee01bca27a957c5bef67121fe8dc93a6554c1.tar.gz
SERVER-48981 Remove invariant to guard against negative fastcount for biggie.
Local isolation of the count is required to prevent negative values because how this storage engine emits write conflict exceptions.
-rw-r--r--src/mongo/db/storage/biggie/biggie_record_store.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mongo/db/storage/biggie/biggie_record_store.cpp b/src/mongo/db/storage/biggie/biggie_record_store.cpp
index fcbddf31c96..38266ff2969 100644
--- a/src/mongo/db/storage/biggie/biggie_record_store.cpp
+++ b/src/mongo/db/storage/biggie/biggie_record_store.cpp
@@ -574,12 +574,16 @@ RecordStore::SizeAdjuster::SizeAdjuster(OperationContext* opCtx, RecordStore* rs
_origDataSize(_workingCopy->dataSize()) {}
RecordStore::SizeAdjuster::~SizeAdjuster() {
+ // SERVER-48981 This implementation of fastcount results in inaccurate values. This storage
+ // engine emits write conflict exceptions at commit-time leading to the fastcount to be
+ // inaccurate until the rollback happens.
+ // If proper local isolation is implemented, SERVER-38883 can also be fulfulled for this storage
+ // engine where we can invariant for correct fastcount in updateStatsAfterRepair()
int64_t deltaNumRecords = _workingCopy->size() - _origNumRecords;
int64_t deltaDataSize = _workingCopy->dataSize() - _origDataSize;
_rs->_numRecords.fetchAndAdd(deltaNumRecords);
_rs->_dataSize.fetchAndAdd(deltaDataSize);
RecoveryUnit::get(_opCtx)->onRollback([rs = _rs, deltaNumRecords, deltaDataSize]() {
- invariant(rs->_numRecords.load() >= deltaNumRecords);
rs->_numRecords.fetchAndSubtract(deltaNumRecords);
rs->_dataSize.fetchAndSubtract(deltaDataSize);
});