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 2017/03/27 18:17:47 UTC

[2/2] mem3 commit: updated refs/heads/COUCHDB-3287-pluggable-storage-engines to 5a1d85b

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.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/commit/5a1d85bc
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/tree/5a1d85bc
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/diff/5a1d85bc

Branch: refs/heads/COUCHDB-3287-pluggable-storage-engines
Commit: 5a1d85bce7ef6f5330c02e1525ea52496c967011
Parents: 5526321
Author: Paul J. Davis <pa...@gmail.com>
Authored: Mon Mar 27 13:16:05 2017 -0500
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Mon Mar 27 13:16:05 2017 -0500

----------------------------------------------------------------------
 src/mem3_shards.erl | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mem3/blob/5a1d85bc/src/mem3_shards.erl
----------------------------------------------------------------------
diff --git a/src/mem3_shards.erl b/src/mem3_shards.erl
index 22eb6de..329f9ed 100644
--- a/src/mem3_shards.erl
+++ b/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))