diff --git a/fdbserver/DDTeamCollection.actor.cpp b/fdbserver/DDTeamCollection.actor.cpp index 8b132c246d..8241ec9aa4 100644 --- a/fdbserver/DDTeamCollection.actor.cpp +++ b/fdbserver/DDTeamCollection.actor.cpp @@ -199,6 +199,9 @@ public: // portion of teams that have longer storage queues // A team storage queue size is defined as the longest storage queue size among all SSes of the team static int64_t calculateTeamStorageQueueThreshold(const std::vector>& teams) { + if (teams.size() == 0) { + return std::numeric_limits::max(); // disable this funcationality + } std::vector queueLengthList; for (const auto& team : teams) { Optional storageQueueSize = team->getLongestStorageQueueSize(); @@ -210,7 +213,7 @@ public: } } double percentile = std::max(0.0, std::min(SERVER_KNOBS->DD_LONG_STORAGE_QUEUE_TEAM_MAJORITY_PERCENTILE, 1.0)); - int position = queueLengthList.size() * (1 - percentile); + int position = (queueLengthList.size() - 1) * (1 - percentile); std::nth_element(queueLengthList.begin(), queueLengthList.begin() + position, queueLengthList.end()); int64_t threshold = queueLengthList[position]; TraceEvent(SevInfo, "StorageQueueAwareGotThreshold").suppressFor(5.0).detail("Threshold", threshold);