Skip to content

Commit

Permalink
MB-42795: Validate magma compaction callback using correct ep engine
Browse files Browse the repository at this point in the history
Change-Id: Ia46e3b2fff58c7280e5dccf46dbf45a72dd29e82
Reviewed-on: http://review.couchbase.org/c/kv_engine/+/142439
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
  • Loading branch information
scottlashley authored and daverigby committed Jan 5, 2021
1 parent 29995e3 commit b0b13f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions engines/ep/src/magma-kvstore/magma-kvstore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ bool MagmaKVStore::compactionCallBack(MagmaKVStore::MagmaCompactionCB& cbCtx,
const magma::Slice& keySlice,
const magma::Slice& metaSlice,
const magma::Slice& valueSlice) {
Expects(currEngine == ObjectRegistry::getCurrentEngine());
// If we are compacting the localDb, items don't have metadata so
// we always keep everything.
if (metaSlice.Len() == 0) {
Expand Down Expand Up @@ -424,7 +425,8 @@ MagmaKVStore::MagmaKVStore(MagmaKVStoreConfig& configuration)
pendingReqs(std::make_unique<PendingRequestQueue>()),
magmaPath(configuration.getDBName() + "/magma." +
std::to_string(configuration.getShardId())),
scanCounter(0) {
scanCounter(0),
currEngine(ObjectRegistry::getCurrentEngine()) {
configuration.magmaCfg.Path = magmaPath;
configuration.magmaCfg.MaxKVStores = configuration.getMaxVBuckets();
configuration.magmaCfg.MaxKVStoreLSDBufferSize =
Expand Down Expand Up @@ -485,8 +487,9 @@ MagmaKVStore::MagmaKVStore(MagmaKVStoreConfig& configuration)
doCheckpointEveryBatch = configuration.getMagmaCheckpointEveryBatch();

// Set up thread and memory tracking.
auto currEngine = ObjectRegistry::getCurrentEngine();
configuration.magmaCfg.SetupThreadContext = [currEngine]() {
// Please note... SetupThreadContext and ResetThreadContext
// will being removed once magma tracking is complete.
configuration.magmaCfg.SetupThreadContext = [this]() {
ObjectRegistry::onSwitchThread(currEngine, false);
};
configuration.magmaCfg.ResetThreadContext = []() {
Expand Down
3 changes: 3 additions & 0 deletions engines/ep/src/magma-kvstore/magma-kvstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -741,4 +741,7 @@ class MagmaKVStore : public KVStore {

folly::Synchronized<std::queue<std::tuple<Vbid, uint64_t>>>
pendingVbucketDeletions;

private:
EventuallyPersistentEngine* currEngine;
};

0 comments on commit b0b13f3

Please sign in to comment.