This is an automated email from the ASF dual-hosted git repository. davisp pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit f040d7531273ce77754ab29e08506951ee228fd6 Author: Paul J. Davis <[email protected]> AuthorDate: Mon Jun 18 12:34:02 2018 -0500 Add set_mqd_off_heap utility function In Erlang VMs starting with version 19.0 have a new process_flag to store messages off the process heap. This is extremely useful for processes that can have huge numbers of messages in their mailbox. For CouchDB this is most usually observed when couch_server backs up with a large message queue which wedges the entire node. This utility function will set a process's message_queue_data flag to off_heap in a way that doesn't break builds of CouchDB on older Erlang VMs while automatically enabling the flag on VMs that do support it. --- src/couch/src/couch_util.erl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/couch/src/couch_util.erl b/src/couch/src/couch_util.erl index f3a9249..af1c0ef 100644 --- a/src/couch/src/couch_util.erl +++ b/src/couch/src/couch_util.erl @@ -37,6 +37,7 @@ -export([unique_monotonic_integer/0]). -export([check_config_blacklist/1]). -export([check_md5/2]). +-export([set_mqd_off_heap/0]). -include_lib("couch/include/couch_db.hrl"). @@ -639,6 +640,15 @@ check_md5(Sig, Sig) -> ok; check_md5(_, _) -> throw(md5_mismatch). +set_mqd_off_heap() -> + try + erlang:process_flag(message_queue_data, off_heap), + ok + catch error:badarg -> + ok + end. + + ensure_loaded(Module) when is_atom(Module) -> case code:ensure_loaded(Module) of {module, Module} ->
