couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [couchdb] 03/03: Avoid overloading mem3_shards
Date Thu, 06 Apr 2017 17:36:01 GMT
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch COUCHDB-3287-pluggable-storage-engines
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit d755f1a64c2b84a7d3f35e21be1171e0dce42301
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
AuthorDate: Mon Mar 27 13:16:05 2017 -0500

    Avoid overloading mem3_shards
    
    This attempts to prevent overload on mem3_shards by skipping cache
    insertions when the mem3_shards gen_server has a mailbox with more than
    five thousand messages.
---
 src/mem3/src/mem3_shards.erl | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mem3/src/mem3_shards.erl b/src/mem3/src/mem3_shards.erl
index 22eb6de..329f9ed 100644
--- a/src/mem3/src/mem3_shards.erl
+++ b/src/mem3/src/mem3_shards.erl
@@ -344,7 +344,12 @@ load_shards_from_db(ShardDb, DbName) ->
     {ok, #doc{body = {Props}}} ->
         Seq = couch_db:get_update_seq(ShardDb),
         Shards = mem3_util:build_ordered_shards(DbName, Props),
-        gen_server:cast(?MODULE, {cache_insert, DbName, Shards, Seq}),
+        case erlang:process_info(whereis(?MODULE), message_queue_len) of
+            {_, N} when is_integer(N), N < 5000 ->
+                gen_server:cast(?MODULE, {cache_insert, DbName, Shards, Seq});
+            _ ->
+                ok
+        end,
         Shards;
     {not_found, _} ->
         erlang:error(database_does_not_exist, ?b2l(DbName))

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <commits@couchdb.apache.org>.

Mime
View raw message