NOTE: 7.0+ is not affected by this issue
During upgrade from <6.6.1 to 6.6.2+, a new stat is added and tracked in _local/vbstate to count the bytes in on-disk Prepares - see
There is a bug in how the updates to this stat are handled during compaction - the value is not clamped to zero and hence can underflow - see https://github.com/couchbase/kv_engine/blob/v6.6.1/engines/ep/src/couch-kvstore/couch-kvstore.cc#L1325-L1327 :
Note that if ctx.stats.prepareBytesPurged is greater than prepareBytes read from disk, the value written will underflow to a negative number - or very large positive if represented as a unsigned value.
This issue was fixed in 7.0.0 upwards as part of http://review.couchbase.org/c/kv_engine/+/140801/4/engines/ep/src/couch-kvstore/couch-kvstore.cc#1585 when this code was merged into the master branch at the time. Unfortunately it wasn't flagged as a customer-impacting bug and hence was not tracked as affecting v.6.6.x.
|For Gerrit Dashboard: MB-48923|
|163890,2||MB-48923: Avoid underflow of on_disk_prepare_bytes during compaction||mad-hatter||kv_engine||Status: MERGED||+2||+1|
|165460,3||MB-48923: Merge commit '93350e0d6' into cheshire-cat||cheshire-cat||kv_engine||Status: MERGED||+2||+1|
|166234,1||Merge branch 'cheshire-cat'||master||kv_engine||Status: MERGED||+2||+1|