From c45daf6f512ad663927536de4ce9db1729c928ce Mon Sep 17 00:00:00 2001 From: Neethu Haneesha Bingi Date: Fri, 13 Aug 2021 01:14:52 -0700 Subject: [PATCH] Disabling option for removing eagerReads for ClearRange mutations. --- fdbclient/ServerKnobs.cpp | 1 + fdbclient/ServerKnobs.h | 1 + fdbserver/storageserver.actor.cpp | 29 +++++++++++++++++------------ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/fdbclient/ServerKnobs.cpp b/fdbclient/ServerKnobs.cpp index 3437186209..2ed56c64e5 100644 --- a/fdbclient/ServerKnobs.cpp +++ b/fdbclient/ServerKnobs.cpp @@ -627,6 +627,7 @@ void ServerKnobs::initialize(Randomize randomize, ClientKnobs* clientKnobs, IsSi init( FETCH_KEYS_TOO_LONG_TIME_CRITERIA, 300.0 ); init( MAX_STORAGE_COMMIT_TIME, 120.0 ); //The max fsync stall time on the storage server and tlog before marking a disk as failed init( RANGESTREAM_LIMIT_BYTES, 2e6 ); if( randomize && BUGGIFY ) RANGESTREAM_LIMIT_BYTES = 1; + init( ENABLE_CLEAR_RANGE_EAGER_READS, true ); //Wait Failure init( MAX_OUTSTANDING_WAIT_FAILURE_REQUESTS, 250 ); if( randomize && BUGGIFY ) MAX_OUTSTANDING_WAIT_FAILURE_REQUESTS = 2; diff --git a/fdbclient/ServerKnobs.h b/fdbclient/ServerKnobs.h index 82dbd227b0..d3dd077a4c 100644 --- a/fdbclient/ServerKnobs.h +++ b/fdbclient/ServerKnobs.h @@ -563,6 +563,7 @@ public: double FETCH_KEYS_TOO_LONG_TIME_CRITERIA; double MAX_STORAGE_COMMIT_TIME; int64_t RANGESTREAM_LIMIT_BYTES; + bool ENABLE_CLEAR_RANGE_EAGER_READS; // Wait Failure int MAX_OUTSTANDING_WAIT_FAILURE_REQUESTS; diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 15a06b5ce5..76170d79c9 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -241,10 +241,12 @@ struct UpdateEagerReadInfo { void addMutation(MutationRef const& m) { // SOMEDAY: Theoretically we can avoid a read if there is an earlier overlapping ClearRange - if (m.type == MutationRef::ClearRange && !m.param2.startsWith(systemKeys.end)) + if (m.type == MutationRef::ClearRange && !m.param2.startsWith(systemKeys.end) && + SERVER_KNOBS->ENABLE_CLEAR_RANGE_EAGER_READS) keyBegin.push_back(m.param2); else if (m.type == MutationRef::CompareAndClear) { - keyBegin.push_back(keyAfter(m.param1, arena)); + if (SERVER_KNOBS->ENABLE_CLEAR_RANGE_EAGER_READS) + keyBegin.push_back(keyAfter(m.param1, arena)); if (keys.size() > 0 && keys.back().first == m.param1) { // Don't issue a second read, if the last read was equal to the current key. // CompareAndClear is likely to be used after another atomic operation on same key. @@ -260,8 +262,10 @@ struct UpdateEagerReadInfo { } void finishKeyBegin() { - std::sort(keyBegin.begin(), keyBegin.end()); - keyBegin.resize(std::unique(keyBegin.begin(), keyBegin.end()) - keyBegin.begin()); + if (SERVER_KNOBS->ENABLE_CLEAR_RANGE_EAGER_READS) { + std::sort(keyBegin.begin(), keyBegin.end()); + keyBegin.resize(std::unique(keyBegin.begin(), keyBegin.end()) - keyBegin.begin()); + } std::sort(keys.begin(), keys.end(), [](const std::pair& lhs, const std::pair& rhs) { return (lhs.first < rhs.first) || (lhs.first == rhs.first && lhs.second > rhs.second); }); @@ -2377,21 +2381,22 @@ void getQueuingMetrics(StorageServer* self, StorageQueuingMetricsRequest const& ACTOR Future doEagerReads(StorageServer* data, UpdateEagerReadInfo* eager) { eager->finishKeyBegin(); - vector> keyEnd(eager->keyBegin.size()); - for (int i = 0; i < keyEnd.size(); i++) - keyEnd[i] = data->storage.readNextKeyInclusive(eager->keyBegin[i]); + if (SERVER_KNOBS->ENABLE_CLEAR_RANGE_EAGER_READS) { + vector> keyEnd(eager->keyBegin.size()); + for (int i = 0; i < keyEnd.size(); i++) + keyEnd[i] = data->storage.readNextKeyInclusive(eager->keyBegin[i]); - state Future> futureKeyEnds = getAll(keyEnd); + state Future> futureKeyEnds = getAll(keyEnd); + state vector keyEndVal = wait(futureKeyEnds); + eager->keyEnd = keyEndVal; + } vector>> value(eager->keys.size()); for (int i = 0; i < value.size(); i++) value[i] = data->storage.readValuePrefix(eager->keys[i].first, eager->keys[i].second); state Future>> futureValues = getAll(value); - state vector keyEndVal = wait(futureKeyEnds); vector> optionalValues = wait(futureValues); - - eager->keyEnd = keyEndVal; eager->value = optionalValues; return Void(); @@ -2500,7 +2505,7 @@ bool expandMutation(MutationRef& m, i = d.lastLessOrEqual(m.param2); if (i && i->isClearTo() && i->getEndKey() >= m.param2) { m.param2 = i->getEndKey(); - } else { + } else if (SERVER_KNOBS->ENABLE_CLEAR_RANGE_EAGER_READS) { // Expand to the next set or clear (from storage or latestVersion), and if it // is a clear, engulf it as well i = d.lower_bound(m.param2);