You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2020/04/09 17:54:24 UTC
[couchdb] 01/01: Fix division by zero
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch fix-couch-rate-limiter-bug
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 7ff8d7423bf27538545ad658617164b433c0f3f7
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Thu Apr 9 10:42:18 2020 -0500
Fix division by zero
---
src/couch_rate/src/couch_rate_limiter.erl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/couch_rate/src/couch_rate_limiter.erl b/src/couch_rate/src/couch_rate_limiter.erl
index 349da8d..6c89666 100644
--- a/src/couch_rate/src/couch_rate_limiter.erl
+++ b/src/couch_rate/src/couch_rate_limiter.erl
@@ -137,7 +137,7 @@ budget(Id, #?STATE{} = State) ->
{max(1, round(R * MultiplicativeFactor)), State};
underloaded ->
ReadWriteRatio = min(1, MR / max(1, MW)),
- SingleWrite = Latency / W,
+ SingleWrite = max(1, Latency / max(1, W)),
EstimatedWrites = floor(Target / SingleWrite),
{max(1, round(ReadWriteRatio * EstimatedWrites)), State};
init ->