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/07/20 19:17:34 UTC

[couchdb] branch optimize-ddoc-cache updated (e87bbe7 -> ee00280)

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

davisp pushed a change to branch optimize-ddoc-cache
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


    omit e87bbe7  FIXUP: Process processes in the process of dying
     new ee00280  FIXUP: Process processes in the process of dying

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (e87bbe7)
            \
             N -- N -- N   refs/heads/optimize-ddoc-cache (ee00280)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/ddoc_cache/test/ddoc_cache_entry_test.erl | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

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

[couchdb] 01/01: FIXUP: Process processes in the process of dying

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch optimize-ddoc-cache
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit ee00280fea0698fa30cab2bd78f0818dc67cee42
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Thu Jul 20 14:02:57 2017 -0500

    FIXUP: Process processes in the process of dying
    
    Turns out we could go to evict an entry just after it had decided to
    leave the cache (i.e., its ddoc was just deleted). When that happens
    ddoc_cache_lru would die trying to shut the process down becuase the
    process died normal earlier than expected.
---
 src/ddoc_cache/src/ddoc_cache_entry.erl       | 20 +++++++++++++++-----
 src/ddoc_cache/test/ddoc_cache_entry_test.erl | 17 +++++++++++++++++
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/src/ddoc_cache/src/ddoc_cache_entry.erl b/src/ddoc_cache/src/ddoc_cache_entry.erl
index 63a2efa..77539eb 100644
--- a/src/ddoc_cache/src/ddoc_cache_entry.erl
+++ b/src/ddoc_cache/src/ddoc_cache_entry.erl
@@ -77,7 +77,17 @@ start_link(Key, Default) ->
 
 
 shutdown(Pid) ->
-    ok = gen_server:call(Pid, shutdown).
+    Ref = erlang:monitor(process, Pid),
+    ok = gen_server:cast(Pid, shutdown),
+    receive
+        {'DOWN', Ref, process, Pid, normal} ->
+            ok;
+        {'DOWN', Ref, process, Pid, Reason} ->
+            erlang:exit(Reason)
+    after ?SHUTDOWN_TIMEOUT ->
+        erlang:demonitor(Ref, [flush]),
+        erlang:exit({timeout, {entry_shutdown, Pid}})
+    end.
 
 
 open(Pid, Key) ->
@@ -170,10 +180,6 @@ handle_call(open, From, #st{opener = Pid} = St) when is_pid(Pid) ->
 handle_call(open, _From, St) ->
     {reply, St#st.val, St};
 
-handle_call(shutdown, _From, St) ->
-    remove_from_cache(St),
-    {stop, normal, ok, St};
-
 handle_call(Msg, _From, St) ->
     {stop, {bad_call, Msg}, {bad_call, Msg}, St}.
 
@@ -227,6 +233,10 @@ handle_cast(refresh, #st{opener = Pid} = St) when is_pid(Pid) ->
     },
     {noreply, NewSt};
 
+handle_cast(shutdown, St) ->
+    remove_from_cache(St),
+    {stop, normal, St};
+
 handle_cast(Msg, St) ->
     {stop, {bad_cast, Msg}, St}.
 
diff --git a/src/ddoc_cache/test/ddoc_cache_entry_test.erl b/src/ddoc_cache/test/ddoc_cache_entry_test.erl
index 381185c..c481bcf 100644
--- a/src/ddoc_cache/test/ddoc_cache_entry_test.erl
+++ b/src/ddoc_cache/test/ddoc_cache_entry_test.erl
@@ -52,6 +52,7 @@ check_entry_test_() ->
             fun kill_opener_on_terminate/1,
             fun evict_when_not_accessed/1,
             fun open_dead_entry/1,
+            fun handles_bad_shutdown/1,
             fun handles_bad_messages/1,
             fun handles_code_change/1
         ]}
@@ -125,6 +126,22 @@ open_dead_entry({DbName, _}) ->
     ?assertEqual(recover(DbName), ddoc_cache_entry:open(Pid, Key)).
 
 
+handles_bad_shutdown(_) ->
+    ErrorPid = spawn(fun() ->
+        receive
+           _ -> exit(bad_shutdown)
+        end
+    end),
+    ?assertExit(bad_shutdown, ddoc_cache_entry:shutdown(ErrorPid)),
+    NotDeadYetPid = spawn(fun() ->
+        timer:sleep(infinity)
+    end),
+    ?assertExit(
+            {timeout, {entry_shutdown, NotDeadYetPid}},
+            ddoc_cache_entry:shutdown(NotDeadYetPid)
+        ).
+
+
 handles_bad_messages(_) ->
     CallExpect = {stop, {bad_call, foo}, {bad_call, foo}, baz},
     CastExpect = {stop, {bad_cast, foo}, bar},

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