You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MB-42306 [2/2]: Bias db_data_size by estimate of completed prepares
+Problem+
The couchstore fragmentation calculation is not taking into account
completed Prepares. As such, auto-compaction is not run when expected,
and hence the completed (no longer needed) prepares are not purged.
This happens because couch_disk_data_size (size of "valid" data on
disk) is calculated directly from couchstore's own count of how much
data is in the current B-Tree root.
While completed prepares can be purged when compaction runs (and hence
are conceptually 'stale' data), completed Prepares are conceptually
"valid" data from couchstore's POV - they are just documents with a
different key prefix which happen to have a seqno below the
high_completed_seqno. As such, couch_disk_data_size includes all
prepares, outstanding and completed.
+Solution+
Ideally KV-Engine would track the total size of all on-disk completed
Prepares (whose which can be purged), and subtract that value from the
couchstore-tracked couch_disk_data_size. However, that is costly to
track accurately - we would have to perform B-Tree seqno scan from 0
to the highCompletedSeqno, accumulating the size of all prepares
found, which is an O(N) operation where N = the number of completed
prepares. As such it is not suitable for the ~1s polling which
ns_server makes.
Alternatively (and the approach taken here) we could ignore pending
(incomplete) prepares entirely, and assume that all prepares are
completed. This is based on the observation that prepares have a
maximum of 65s timeout before they are aborted, and most will be
Committed much sooner than that.
This patch therefore:
* Exposes new 'prepare_size' stats, which are the number of bytes of
all on-disk prepares:
- ep_db_prepare_size (from 'all' or 'diskinfo' group)
- vb_XXX:db_prepare_size (from 'vbucket-details' group)
- vb_XXX:prepare_size (from 'diskinfo detail' group)
* Uses the newly-tracked on_disk_prepare_bytes to bias the raw
couchstore-provided couch_disk_data_size stat. This means the
following stats are all reduced by the size of the on-disk prepares:
- ep_db_data_size (from 'all' or 'diskinfo' group)
- vb_XXX:db_data_size (from 'vbucket-details' group)
- vb_XXX:data_size (from 'diskinfo detail' group)
Change-Id: I4da06fe17a68c96ddd03d027aed9696c5a20def8
Reviewed-on: http://review.couchbase.org/c/kv_engine/+/139312
Tested-by: Dave Rigby <[email protected]>
Reviewed-by: James Harrison <[email protected]>
Well-Formed: Build Bot <[email protected]>
0 commit comments