Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions fdbserver/datadistributor/DDRelocationQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,17 @@ void DDQueue::enqueueCancelledDataMove(UID dataMoveId, KeyRange range, const DDE
.detail("Range", range);
}

void DDQueue::dequeueDataMoveOnSuccess(UID dataMoveId, const KeyRangeRef& keys) {
auto move = dataMoves.rangeContaining(keys.begin);
if (move.range() != keys || move.value().id != dataMoveId || move.value().cancel.isValid()) {
return;
}
dataMoves.insert(keys, DDDataMove());
TraceEvent(SevVerbose, "DequeueDataMoveOnSuccess", distributorId)
.detail("DataMoveID", dataMoveId)
.detail("DataMoveRange", keys);
}

void DDQueue::refreshCounter() {
serverCounter.traceAll(distributorId);
serverCounter.clear();
Expand Down Expand Up @@ -2315,14 +2326,7 @@ Future<Void> dataDistributionRelocator(DDQueue* self,
} else {
self->fetchKeysComplete.insert(rd);
if (ddEnabledState->shardEncodeLocationMetadata()) {
auto ranges = self->dataMoves.getAffectedRangesAfterInsertion(rd.keys);
if (ranges.size() == 1 && static_cast<KeyRange>(ranges[0]) == rd.keys &&
ranges[0].value.id == rd.dataMoveId && !ranges[0].value.cancel.isValid()) {
self->dataMoves.insert(rd.keys, DDQueue::DDDataMove());
TraceEvent(SevVerbose, "DequeueDataMoveOnSuccess", self->distributorId)
.detail("DataMoveID", rd.dataMoveId)
.detail("DataMoveRange", rd.keys);
}
self->dequeueDataMoveOnSuccess(rd.dataMoveId, rd.keys);
}
break;
}
Expand Down Expand Up @@ -3368,6 +3372,28 @@ TEST_CASE("/DataDistribution/DDQueue/ServerCounterTrace") {
std::cout << "Finished.";
}

TEST_CASE("/DataDistribution/DDQueue/DequeueDataMoveOnSuccess") {
DDQueue queue;
const KeyRangeRef keys("b"_sr, "d"_sr);
const UID id(1, 1);
auto current = [&] { return queue.dataMoves.rangeContaining(keys.begin); };

queue.dataMoves.insert(keys, DDQueue::DDDataMove(id));
queue.dequeueDataMoveOnSuccess(UID(2, 2), keys);
queue.dequeueDataMoveOnSuccess(id, KeyRangeRef("b"_sr, "c"_sr));
ASSERT(current().range() == keys && current().value().id == id);

queue.dequeueDataMoveOnSuccess(id, keys);
ASSERT(!current().value().isValid());

DDQueue::DDDataMove cancelling(id);
cancelling.cancel = Never();
queue.dataMoves.insert(keys, cancelling);
queue.dequeueDataMoveOnSuccess(id, keys);
ASSERT(current().value().id == id && current().value().cancel.isValid());
co_return;
}

TEST_CASE("/DataDistribution/DDQueue/ReplacementPreservesPipelineCapacity") {
DDQueue self;
self.activeRelocations = SERVER_KNOBS->DD_MAX_PIPELINE_MOVES - 1;
Expand Down
1 change: 1 addition & 0 deletions fdbserver/datadistributor/DDRelocationQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ class DDQueue : public IDDRelocationQueue, public ReferenceCounted<DDQueue> {

// Schedules cancellation of a data move.
void enqueueCancelledDataMove(UID dataMoveId, KeyRange range, const DDEnabledState* ddEnabledState);
void dequeueDataMoveOnSuccess(UID dataMoveId, const KeyRangeRef& keys);

void refreshCounter();

Expand Down
Loading