Created
September 27, 2023 03:06
-
-
Save nickva/9d53e03e54fda24e77daa236b894a346 to your computer and use it in GitHub Desktop.
CouchDB Haproxy With Quick Client Disconnect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| global | |
| maxconn 10000 | |
| spread-checks 5 | |
| defaults | |
| mode http | |
| log global | |
| option httplog | |
| log stdout format raw local0 | |
| balance roundrobin | |
| option redispatch | |
| retries 4 | |
| timeout client 150s | |
| timeout server 360s | |
| timeout connect 500 | |
| option abortonclose | |
| frontend http-in | |
| option clitcpka | |
| clitcpka-cnt 3 | |
| clitcpka-intvl 1s | |
| clitcpka-idle 3s | |
| bind *:5984 | |
| default_backend servers | |
| backend servers | |
| option httpchk GET /_up | |
| server node1 127.0.0.1:15984 check inter 600s | |
Author
nickva
commented
Sep 27, 2023
Author
Issue slow running _find query then abort after a few seconds
% ./slowfindha.py
* deleting http://127.0.0.1:5984/db
* creating http://127.0.0.1:5984/db with q=1
* created http://127.0.0.1:5984/db
* creating 2000 docs
* created docs in 0.3 seconds
* calling _find with selector: {'x': {'$regex': '^(((a+)+)+)+$'}}
^C
Author
Shorten client connection check a bit to avoid waiting too long and show when request process dies
diff --git a/src/chttpd/src/chttpd_util.erl b/src/chttpd/src/chttpd_util.erl
index d77e8d2aa..af7d598c0 100644
--- a/src/chttpd/src/chttpd_util.erl
+++ b/src/chttpd/src/chttpd_util.erl
@@ -31,8 +31,8 @@
]).
-define(MOCHIWEB_CLIENT_REQ, mochiweb_client_req).
--define(DISCONNECT_CHECK_MSEC, 30000).
--define(DISCONNECT_CHECK_JITTER_MSEC, 15000).
+-define(DISCONNECT_CHECK_MSEC, 5000).
+-define(DISCONNECT_CHECK_JITTER_MSEC, 500).
get_chttpd_config(Key) ->
config:get("chttpd", Key, config:get("httpd", Key)).
diff --git a/src/mango/src/mango_httpd.erl b/src/mango/src/mango_httpd.erl
index 8e4b72840..f6d502874 100644
--- a/src/mango/src/mango_httpd.erl
+++ b/src/mango/src/mango_httpd.erl
@@ -205,6 +205,8 @@ handle_explain_req(Req, _Db) ->
chttpd:send_method_not_allowed(Req, "POST").
handle_find_req(#httpd{method = 'POST'} = Req, Db) ->
+ couch_log:error(" ++++++++++TRACING _find++++++++ ~p:~p@~B REQPID:~p", [?MODULE, ?FUNCTION_NAME, ?LINE, self()]),
+ dbg:tracer(), dbg:p(self(), p),
chttpd:validate_ctype(Req, "application/json"),
Body = maybe_set_partition(Req),
{ok, Opts0} = mango_opts:validate_find(Body),
Author
CouchDB logs show the request process is killed within 5 seconds or so
[notice] 2023-09-27T03:03:22.837658Z node1@127.0.0.1 <0.18737.0> 47b8291a4c 127.0.0.1:5984 127.0.0.1 adm PUT /db?q=1 201 ok 114
[notice] 2023-09-27T03:03:22.920781Z node1@127.0.0.1 <0.18737.0> e1ca592e21 127.0.0.1:5984 127.0.0.1 adm POST /db/_bulk_docs 201 ok 79
[notice] 2023-09-27T03:03:22.999434Z node1@127.0.0.1 <0.18737.0> fdbba7a0ee 127.0.0.1:5984 127.0.0.1 adm POST /db/_bulk_docs 201 ok 75
[notice] 2023-09-27T03:03:23.075838Z node1@127.0.0.1 <0.18737.0> f9af5e4d9a 127.0.0.1:5984 127.0.0.1 adm POST /db/_bulk_docs 201 ok 73
[notice] 2023-09-27T03:03:23.152235Z node1@127.0.0.1 <0.18737.0> 888ea8db06 127.0.0.1:5984 127.0.0.1 adm POST /db/_bulk_docs 201 ok 73
[error] 2023-09-27T03:03:23.155898Z node1@127.0.0.1 <0.18737.0> b311b36392 ++++++++++TRACING _find++++++++ mango_httpd:handle_find_req@208 REQPID:<0.18737.0>
(<0.18737.0>) spawn <0.19452.0> as erlang:apply(#Fun<rexi_monitor.1.77517421>,[])
(<0.18737.0>) link <0.19452.0>
(<0.18737.0>) spawn <0.19453.0> as erlang:apply(#Fun<fabric_streams.3.91837225>,[])
(<0.18737.0>) exit {shutdown,client_disconnected}
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
