You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wo...@apache.org on 2017/05/02 17:50:39 UTC

[couchdb] branch 3402-mem3-race updated (5cad2a4 -> 1aa48ef)

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

wohali pushed a change to branch 3402-mem3-race
in repository https://gitbox.apache.org/repos/asf/couchdb.git.

     omits  5cad2a4   Fix error on race condition in mem3 startup
       new  1aa48ef   Fix error on race condition in mem3 startup

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   (5cad2a4)
            \
             N -- N -- N   refs/heads/3402-mem3-race (1aa48ef)

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 "omits" are not gone; other references still
refer to them.  Any revisions marked "discards" 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 "adds" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/mem3/src/mem3_shards.erl | 7 +------
 src/mem3/src/mem3_util.erl   | 7 ++++---
 2 files changed, 5 insertions(+), 9 deletions(-)

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

[couchdb] 01/01: Fix error on race condition in mem3 startup

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

wohali pushed a commit to branch 3402-mem3-race
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 1aa48ef245a9f5d8d336d43070767363ef092ed1
Author: Joan Touzet <jo...@atypical.net>
AuthorDate: Sun Apr 30 02:49:20 2017 -0400

    Fix error on race condition in mem3 startup
    
    During mem3 startup, 2 paths attempt to call `couch_server:create/2` on
    `_dbs`:
    
    ```
    gen_server:init_it/6
      -> mem3_shards:init/1
        -> mem3_shards:get_update_seq/0
          -> couch_server:create/2
    ```
    
    and
    
    ```
    mem3_sync:initial_sync/1
      -> mem3_shards:fold/2
        -> couch_server:create/2
    ```
    
    Normally, the first path completes before the second. If the second path
    finishes first, the first path fails because it does not expect a
    `file_exists` response.
    
    This patch makes `mem3_util:ensure_enxists/1` more robust in the face of
    a race to create `_dbs`.
    
    Fixes COUCHDB-3402.
    
    Approved by @davisp and @iilyak
---
 src/mem3/src/mem3_util.erl | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/mem3/src/mem3_util.erl b/src/mem3/src/mem3_util.erl
index 2cd444d..71ef5b6 100644
--- a/src/mem3/src/mem3_util.erl
+++ b/src/mem3/src/mem3_util.erl
@@ -214,11 +214,12 @@ shard_info(DbName) ->
 ensure_exists(DbName) when is_list(DbName) ->
     ensure_exists(list_to_binary(DbName));
 ensure_exists(DbName) ->
-    case couch_db:open(DbName, [nologifmissing, sys_db | [?ADMIN_CTX]]) of
+    Options = [nologifmissing, sys_db, {create_if_missing, true}, ?ADMIN_CTX],
+    case couch_db:open(DbName, Options) of
     {ok, Db} ->
         {ok, Db};
-    _ ->
-        couch_server:create(DbName, [?ADMIN_CTX])
+    file_exists ->
+        couch_db:open(DbName, [sys_db, ?ADMIN_CTX])
     end.
 
 

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