From 99d9b4e727a362e90545fd8f36ef949cf2153132 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Thu, 8 Dec 2016 13:43:45 -0500 Subject: [PATCH] commitlog: correctly report requests blocked The semaphore future may be unavailable for many reasons. Specifically, if the task quota is depleted right between sem.wait() and the .then() clause in get_units() the resulting future won't be available. That is particularly visible if we decrease the task quota, since those events will be more frequent: we can in those cases clearly see this counter going up, even though there aren't more requests pending than usual. This patch improves the situation by replacing that check. We now verify whether or not there are waiters in the semaphore. Signed-off-by: Glauber Costa Message-Id: <113c0d6b43cd6653ce972541baf6920e5765546b.1481222621.git.glauber@scylladb.com> (cherry picked from commit 9b5e6d6bd82d5d5c5171c5b10ea67994413c6693) --- db/commitlog/commitlog.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/commitlog/commitlog.cc b/db/commitlog/commitlog.cc index 58c1a71f81..3025abc1c3 100644 --- a/db/commitlog/commitlog.cc +++ b/db/commitlog/commitlog.cc @@ -874,7 +874,7 @@ db::commitlog::segment_manager::allocate_when_possible(const cf_id_type& id, sha } auto fut = get_units(_request_controller, size); - if (!fut.available()) { + if (_request_controller.waiters()) { totals.requests_blocked_memory++; } return fut.then([this, id, writer = std::move(writer)] (auto permit) mutable {