Details
-
Bug
-
Resolution: Fixed
-
Minor
-
Cheshire-Cat
-
Untriaged
-
Unknown
Description
This is a theatrical bug that might occur in the future if we allow compaction to occur at the same time that the PersistenceCallback's are being called after a flush. This could cause us to potentially lose an increment or decrements to the onDiskTotalItems counter. Thus meaning in full eviction our "current item count" would be incorrect.
This is due to a race occurring between one of the PersistenceCallback s incrementing or decrementing the count and EPBucket::compactionCompletionCallback setting the value as setNumTotalItems() isn't thread safe and blindly sets the value of onDiskTotalItems thus we should perform an atomic subtraction on onDiskTotalItems of value ctx.stats.collectionsItemsPurged.
void EPBucket::compactionCompletionCallback(compaction_ctx& ctx) { |
auto vb = getVBucket(ctx.compactConfig.db_file_id);
|
if (!vb) { |
return; |
}
|
|
vb->setPurgeSeqno(ctx.max_purged_seq);
|
vb->setNumTotalItems(vb->getNumTotalItems() -
|
ctx.stats.collectionsItemsPurged);
|
}
|
This code was originally first added in a different form in commit 4d6df4c1e177ffc5673b8cefc44cecbf5fa42477.