2525#include " dcp/backfill_by_seqno_disk.h"
2626#include " durability/active_durability_monitor.h"
2727#include " durability/passive_durability_monitor.h"
28+ #include " ep_bucket.h"
2829#include " ep_engine.h"
2930#include " ep_time.h"
3031#include " executorpool.h"
@@ -56,6 +57,7 @@ EPVBucket::EPVBucket(Vbid i,
5657 Configuration& config,
5758 EvictionPolicy evictionPolicy,
5859 std::unique_ptr<Collections::VB::Manifest> manifest,
60+ EPBucket* bucket,
5961 vbucket_state_t initState,
6062 uint64_t purgeSeqno,
6163 uint64_t maxCas,
@@ -87,7 +89,8 @@ EPVBucket::EPVBucket(Vbid i,
8789 mightContainXattrs,
8890 replicationTopology,
8991 maxVisibleSeqno),
90- shard(kvshard) {
92+ shard(kvshard),
93+ epBucket(bucket) {
9194}
9295
9396EPVBucket::~EPVBucket () {
@@ -596,7 +599,7 @@ size_t EPVBucket::getPageableMemUsage() {
596599
597600size_t EPVBucket::queueBGFetchItem (const DocKey& key,
598601 std::unique_ptr<BGFetchItem> fetch,
599- BgFetcher* bgFetcher) {
602+ BgFetcher& bgFetcher) {
600603 // While a DiskDocKey supports both the committed and prepared namespaces,
601604 // ep-engine doesn't support evicting prepared SyncWrites and as such
602605 // we don't allow bgfetching from Prepared namespace - so just construct
@@ -616,7 +619,7 @@ size_t EPVBucket::queueBGFetchItem(const DocKey& key,
616619 fetch->value = &bgfetch_itm_ctx.value ;
617620 bgfetch_itm_ctx.bgfetched_list .push_back (std::move (fetch));
618621
619- bgFetcher-> addPendingVB (getId ());
622+ bgFetcher. addPendingVB (getId ());
620623 return pendingBGFetches.size ();
621624}
622625
@@ -747,12 +750,14 @@ void EPVBucket::bgFetch(const DocKey& key,
747750 const void * cookie,
748751 EventuallyPersistentEngine& engine,
749752 const bool isMeta) {
753+ // @TODO could the BgFetcher ever not be there? It should probably be a
754+ // reference if that's the case
750755 // schedule to the current batch of background fetch of the given
751756 // vbucket
752757 size_t bgfetch_size = queueBGFetchItem (
753758 key,
754759 std::make_unique<FrontEndBGFetchItem>(cookie, isMeta),
755- getShard ()-> getBgFetcher ());
760+ getBgFetcher ());
756761 EP_LOG_DEBUG (" Queued a background fetch, now at {}" ,
757762 uint64_t (bgfetch_size));
758763}
@@ -780,12 +785,9 @@ void EPVBucket::bgFetchForCompactionExpiry(const DocKey& key,
780785 const Item& item) {
781786 // schedule to the current batch of background fetch of the given
782787 // vbucket
783- auto shard = getShard ();
784- Expects (shard);
785- auto bgFetchSize =
786- queueBGFetchItem (key,
787- std::make_unique<CompactionBGFetchItem>(item),
788- shard->getBgFetcher ());
788+ auto & bgFetcher = getBgFetcher ();
789+ auto bgFetchSize = queueBGFetchItem (
790+ key, std::make_unique<CompactionBGFetchItem>(item), bgFetcher);
789791 EP_LOG_DEBUG (" Queue a background fetch for compaction expiry, now at {}" ,
790792 bgFetchSize);
791793}
@@ -1019,3 +1021,7 @@ void EPVBucket::processImplicitlyCompletedPrepare(
10191021 // used after.
10201022 ht.unlocked_del (v.getHBL (), v.release ());
10211023}
1024+
1025+ BgFetcher& EPVBucket::getBgFetcher () {
1026+ return epBucket->getBgFetcher (getId ());
1027+ }
0 commit comments