@@ -58,36 +58,25 @@ void Flush::StatisticsUpdate::updateDiskSize(ssize_t delta) {
5858}
5959
6060void Flush::StatisticsUpdate::insert (bool isSystem,
61- bool isCommitted,
6261 bool isDelete,
6362 ssize_t diskSizeDelta) {
64- if (!isSystem && !isDelete && isCommitted ) {
63+ if (!isSystem && !isDelete) {
6564 incrementItemCount ();
66- } // else inserting a tombstone or it's a prepare
65+ } // else inserting a tombstone - no item increment
6766
68- if (isSystem || isCommitted) {
69- updateDiskSize (diskSizeDelta);
70- }
67+ updateDiskSize (diskSizeDelta);
7168}
7269
73- void Flush::StatisticsUpdate::update (bool isSystem,
74- bool isCommitted,
75- ssize_t diskSizeDelta) {
76- if (isSystem || isCommitted) {
77- updateDiskSize (diskSizeDelta);
78- }
70+ void Flush::StatisticsUpdate::update (ssize_t diskSizeDelta) {
71+ updateDiskSize (diskSizeDelta);
7972}
8073
8174void Flush::StatisticsUpdate::remove (bool isSystem,
82- bool isCommitted,
8375 ssize_t diskSizeDelta) {
84- if (isCommitted ) {
76+ if (!isSystem ) {
8577 decrementItemCount ();
86- } // else inserting a tombstone or it's a prepare
87-
88- if (isSystem || isCommitted) {
89- updateDiskSize (diskSizeDelta);
9078 }
79+ updateDiskSize (diskSizeDelta);
9180}
9281
9382// Called from KVStore during the flush process and before we consider the
@@ -195,6 +184,10 @@ void Flush::updateStats(const DocKey& key,
195184 bool isCommitted,
196185 bool isDelete,
197186 size_t size) {
187+ // Prepares don't change the stats
188+ if (!isCommitted) {
189+ return ;
190+ }
198191 auto [isSystemEvent, cid] = getCollectionID (key);
199192
200193 if (!cid || isLogicallyDeleted (cid.value (), seqno)) {
@@ -209,7 +202,7 @@ void Flush::updateStats(const DocKey& key,
209202 }
210203
211204 getStatsAndMaybeSetPersistedHighSeqno (cid.value (), seqno)
212- .insert (isSystemEvent, isCommitted, isDelete, size);
205+ .insert (isSystemEvent, isDelete, size);
213206}
214207
215208void Flush::updateStats (const DocKey& key,
@@ -220,6 +213,10 @@ void Flush::updateStats(const DocKey& key,
220213 uint64_t oldSeqno,
221214 bool oldIsDelete,
222215 size_t oldSize) {
216+ // Prepares don't change the stats
217+ if (!isCommitted) {
218+ return ;
219+ }
223220 // Same logic and comment as updateStats above.
224221 auto [isSystemEvent, cid] = getCollectionID (key);
225222 if (!cid || isLogicallyDeleted (cid.value (), seqno)) {
@@ -239,11 +236,11 @@ void Flush::updateStats(const DocKey& key,
239236 auto & stats = getStatsAndMaybeSetPersistedHighSeqno (cid.value (), seqno);
240237
241238 if (oldIsDelete) {
242- stats.insert (isSystemEvent, isCommitted, isDelete, size);
239+ stats.insert (isSystemEvent, isDelete, size);
243240 } else if (!oldIsDelete && isDelete) {
244- stats.remove (isSystemEvent, isCommitted, size - oldSize);
241+ stats.remove (isSystemEvent, size - oldSize);
245242 } else {
246- stats.update (isSystemEvent, isCommitted, size - oldSize);
243+ stats.update (size - oldSize);
247244 }
248245}
249246
0 commit comments