You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2020/08/19 14:17:08 UTC

[couchdb] branch prototype/fdb-layer updated: add has_failures to couch_rate_limiter (#3088)

This is an automated email from the ASF dual-hosted git repository.

garren pushed a commit to branch prototype/fdb-layer
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/prototype/fdb-layer by this push:
     new 1c0c9f4  add has_failures to couch_rate_limiter (#3088)
1c0c9f4 is described below

commit 1c0c9f40225668a67e73d11583c7bd22c042d1f2
Author: garren smith <ga...@gmail.com>
AuthorDate: Wed Aug 19 16:16:55 2020 +0200

    add has_failures to couch_rate_limiter (#3088)
    
    Fixes the case where no writes are done for an index, the rater limiter
    assumed it was a failure.
---
 src/couch_rate/src/couch_rate_limiter.erl | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/couch_rate/src/couch_rate_limiter.erl b/src/couch_rate/src/couch_rate_limiter.erl
index 6f852b1..97a6302 100644
--- a/src/couch_rate/src/couch_rate_limiter.erl
+++ b/src/couch_rate/src/couch_rate_limiter.erl
@@ -80,7 +80,8 @@
     regular_delay = 100 :: timeout(),
     congested_delay = 5000 :: timeout(),
     initial_budget = 100,
-    latency = 0
+    latency = 0,
+    has_failures = false
 }).
 
 -type state() :: #?STATE{}.
@@ -199,7 +200,8 @@ success(_Id, #?STATE{} = State, Writes) ->
         writes = Writes,
         mean_writes = average(MeanWrites, WinSize, Writes),
         mean_reads = average(MeanReads, WinSize, Reads),
-        latency = TimerFun() - TS
+        latency = TimerFun() - TS,
+        has_failures = false
     })}.
 
 
@@ -215,7 +217,8 @@ failure(_Id, #?STATE{} = State) ->
     } = State,
     {ok, update_min(State#?STATE{
         writes = 0,
-        latency = TimerFun() - TS
+        latency = TimerFun() - TS,
+        has_failures = true
     })}.
 
 
@@ -266,18 +269,18 @@ pattern(Id, #?STATE{} = State) ->
     #?STATE{
         underload_threshold = UnderloadThreshold,
         overload_threshold = OverloadThreshold,
-        writes = W,
-        mean_writes = MW
+        mean_writes = MW,
+        has_failures = HasFailures
     } = State,
     case min_latency(Id, State) of
         MinRollingLatency when MinRollingLatency > OverloadThreshold ->
             overloaded;
         MinRollingLatency when MinRollingLatency > UnderloadThreshold ->
             optimal;
-        MinRollingLatency when MinRollingLatency > 0 andalso W == 0 ->
-            failed;
         MinRollingLatency when MinRollingLatency == 0 andalso MW == 0.0 ->
             init;
+        _ when HasFailures ->
+            failed;
         _ ->
             underloaded
     end.