Skip to content

Commit 87efeb9

Browse files
committed
MB-58531: Iterate through collections for oso auto backfill
Change from using the single cid (from filter.front) to iterating the filter and computing a total collection size for use in the auto calculation. Note that only 1 collection will currently be in the filter when reaching the iteration. Change-Id: Idceeddfb3a579f18c15a43bf7bd6256e599b1947 Reviewed-on: https://review.couchbase.org/c/kv_engine/+/197003 Reviewed-by: Trond Norbye <[email protected]> Tested-by: Jim Walker <[email protected]>
1 parent 6118211 commit 87efeb9

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

engines/ep/src/dcp/active_stream.cc

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,6 @@ bool ActiveStream::tryAndScheduleOSOBackfill(DcpProducer& producer,
20362036
if (producer.isOutOfOrderSnapshotsEnabled() && filter.singleCollection() &&
20372037
lastReadSeqno.load() == 0 &&
20382038
((curChkSeqno.load() > lastReadSeqno.load() + 1) || (isDiskOnly()))) {
2039-
CollectionID cid = filter.front();
20402039

20412040
// however OSO is only _used_ if:
20422041
// - dcp_oso_backfill is set to enabled,
@@ -2048,21 +2047,25 @@ bool ActiveStream::tryAndScheduleOSOBackfill(DcpProducer& producer,
20482047
return false;
20492048
}
20502049
if (osoBackfill == "auto") {
2051-
// Retrieve collection stats from manifest; minimising the scope
2052-
// of manifest lock.
2053-
const auto [colItemCount, colDiskSize] = [&vb, cid] {
2050+
size_t colItemCount = 0, colDiskSize = 0;
2051+
2052+
// For each collection, obtain the item count and disk size
2053+
for (auto [cid, sid] : filter) {
2054+
(void)sid;
20542055
const auto stats = vb.getManifest().lock(cid);
2055-
return std::pair{stats.getItemCount(), stats.getDiskSize()};
2056-
}();
2056+
colItemCount += stats.getItemCount();
2057+
colDiskSize += stats.getDiskSize();
2058+
}
2059+
20572060
const auto vbItemCount = vb.getNumItems();
20582061
if (!isOSOPreferredForCollectionBackfill(
20592062
config, colItemCount, colDiskSize, vbItemCount)) {
20602063
log(spdlog::level::level_enum::info,
2061-
"{} Skipping OSO backfill for cid:{} as collection item "
2064+
"{} Skipping OSO backfill of size:{} total collection item "
20622065
"count ({}) is too large a percentage of the vBucket item "
20632066
"count ({}) - ({:.2f}%)",
20642067
logPrefix,
2065-
cid,
2068+
filter.size(),
20662069
colItemCount,
20672070
vbItemCount,
20682071
(float(colItemCount) * 100) / vbItemCount);
@@ -2080,9 +2083,9 @@ bool ActiveStream::tryAndScheduleOSOBackfill(DcpProducer& producer,
20802083
// CheckpointManager
20812084
log(spdlog::level::level_enum::info,
20822085
"{} Scheduling OSO backfill "
2083-
"for cid:{} diskOnly:{} lastReadSeqno:{} curChkSeqno:{}",
2086+
"for size:{} diskOnly:{} lastReadSeqno:{} curChkSeqno:{}",
20842087
logPrefix,
2085-
cid.to_string(),
2088+
filter.size(),
20862089
isDiskOnly(),
20872090
lastReadSeqno.load(),
20882091
curChkSeqno.load());

0 commit comments

Comments
 (0)