Skip to content

Commit 17c6db7

Browse files
committed
MB-64001: CacheTransferStream::maybeQueueItem is too big
Move all StoredValue "skip" checks to a separate function. Change-Id: If028ce437d749ebbde53ab533b16a8d59de5013b Reviewed-on: https://review.couchbase.org/c/kv_engine/+/235485 Reviewed-by: Trond Norbye <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent 1e02b9b commit 17c6db7

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

engines/ep/src/dcp/cache_transfer_stream.cc

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -401,17 +401,15 @@ size_t CacheTransferStream::getMemoryUsed() const {
401401
return engine.getEpStats().getEstimatedTotalMemoryUsed();
402402
}
403403

404-
CacheTransferStream::Status CacheTransferStream::maybeQueueItem(
405-
const StoredValue& sv, Collections::VB::ReadHandle& readHandle) {
406-
preQueueCallback(sv);
407-
404+
bool CacheTransferStream::skip(const StoredValue& sv,
405+
Collections::VB::ReadHandle& readHandle) const {
408406
// Check if the sv is eligible for transfer.
409407
// 1. Temporary/Deleted/Pending StoredValues are not eligible.
410408
if (sv.isTempItem() || sv.isDeleted() || sv.isPending()) {
411409
OBJ_LOG_DEBUG_CTX(*this,
412410
"CacheTransferStream skipping temp/deleted/pending",
413411
{"sv", nlohmann::json{sv}});
414-
return Status::KeepVisiting;
412+
return true;
415413
}
416414

417415
// 2. Dropped collection items are not eligible.
@@ -420,7 +418,7 @@ CacheTransferStream::Status CacheTransferStream::maybeQueueItem(
420418
*this,
421419
"CacheTransferStream skipping as in dropped collection",
422420
{"sv", nlohmann::json{sv}});
423-
return Status::KeepVisiting;
421+
return true;
424422
}
425423

426424
// 3. StoredValues with a sequence number greater than the stream's maxSeqno
@@ -430,7 +428,7 @@ CacheTransferStream::Status CacheTransferStream::maybeQueueItem(
430428
*this,
431429
"CacheTransferStream skipping sv with seqno > maxSeqno",
432430
{"sv", nlohmann::json{sv}});
433-
return Status::KeepVisiting;
431+
return true;
434432
}
435433

436434
// 4. Do checks for a value transfer, these don't apply if the only a
@@ -441,15 +439,15 @@ CacheTransferStream::Status CacheTransferStream::maybeQueueItem(
441439
OBJ_LOG_DEBUG_CTX(*this,
442440
"CacheTransferStream skipping non-resident",
443441
{"sv", nlohmann::json{sv}});
444-
return Status::KeepVisiting;
442+
return true;
445443
}
446444

447445
// 4.2 If the sv is expired, it is not eligible.
448446
if (sv.isExpired(ep_real_time())) {
449447
OBJ_LOG_DEBUG_CTX(*this,
450448
"CacheTransferStream skipping expired",
451449
{"sv", nlohmann::json{sv}});
452-
return Status::KeepVisiting;
450+
return true;
453451
}
454452
}
455453

@@ -459,6 +457,18 @@ CacheTransferStream::Status CacheTransferStream::maybeQueueItem(
459457
*this,
460458
"CacheTransferStream skipping as not allowed by filter",
461459
{"sv", nlohmann::json{sv}});
460+
return true;
461+
}
462+
return false;
463+
}
464+
465+
CacheTransferStream::Status CacheTransferStream::maybeQueueItem(
466+
const StoredValue& sv, Collections::VB::ReadHandle& readHandle) {
467+
preQueueCallback(sv);
468+
469+
// Lots of little checks to make to decide if the item found in the
470+
// hash-table should be skipped or queued.
471+
if (skip(sv, readHandle)) {
462472
return Status::KeepVisiting;
463473
}
464474

engines/ep/src/dcp/cache_transfer_stream.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,15 @@ class CacheTransferStream
140140

141141
virtual size_t getMemoryUsed() const;
142142

143+
/**
144+
* Checks if the item should be skipped instead of queueing for transfer.
145+
* @param sv The StoredValue to check.
146+
* @param readHandle The read handle to use for the item.
147+
* @return true if the item should be skipped, false otherwise.
148+
*/
149+
bool skip(const StoredValue& sv,
150+
Collections::VB::ReadHandle& readHandle) const;
151+
143152
/**
144153
* Transitions are either:
145154
* Active -> Dead

0 commit comments

Comments
 (0)