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

[couchdb] 01/01: fix: set gen_server:call() timeout to infinity on ioq bypass

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

jan pushed a commit to branch fix/gen-server-timeout-on-ioq-bypass
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit da20ca8150044ae990206ef4817b3f123a27f1e2
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Thu Jul 2 21:06:24 2020 +0200

    fix: set gen_server:call() timeout to infinity on ioq bypass
    
    Before the bypass existed, ioq would call `gen_server:call()`
    on hehalf of it calling module with the queueing logic in between.
    
    Commit e641a740 introduced a way to bypass any queues, but the
    delegated `gen_server:call()` there was added without a timeout
    parameter, leading to a default timeout of 5000ms.
    
    A problem manifests here when operations that are sent through
    ioq that take longer than that 5000ms timeout. In practice, these
    operations should be very rare and this timeout should be a help
    on overloaded systems. However, one sure-fire way to cause an issue
    on an otherwise idle machine is raise the max_document_size and
    store unreasonably large documents, think 50MB+ of raw JSON).
    
    Not that we recommend this, but folks have run this fine on 2.x
    before the ioq changes and it isn’t too hard to support here.
    
    By adding an `infinity` timeout delegated `gen_server:call()` in
    the queue bypasse case, this no longer applies.
    
    Thanks to Joan @woahli Touzet, Bob @rnewson Newson and
    Paul @davisp Davis for helping to track this down.
---
 src/ioq/src/ioq.erl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/ioq/src/ioq.erl b/src/ioq/src/ioq.erl
index 81d94a3..99b3ce3 100644
--- a/src/ioq/src/ioq.erl
+++ b/src/ioq/src/ioq.erl
@@ -45,7 +45,7 @@ call(Fd, Msg, Metadata) ->
     Priority = io_class(Msg, Metadata),
     case bypass(Priority) of
         true ->
-            gen_server:call(Fd, Msg);
+            gen_server:call(Fd, Msg, infinity);
         false ->
             queued_call(Fd, Msg, Priority)
     end.