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 2019/05/07 17:00:42 UTC

[couchdb] branch fix-epoch-mismatch-error created (now 54aebc7)

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

davisp pushed a change to branch fix-epoch-mismatch-error
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at 54aebc7  Fix epoch mismatch errors

This branch includes the following new commits:

     new 54aebc7  Fix epoch mismatch errors

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.



[couchdb] 01/01: Fix epoch mismatch errors

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

davisp pushed a commit to branch fix-epoch-mismatch-error
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 54aebc745d807eec9a12900a138333fb121978e0
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Tue May 7 11:59:11 2019 -0500

    Fix epoch mismatch errors
    
    Originally we posited that duplicate UUIDs could never be created.
    However due to operations interventions its possible to unintentionally
    copy UUIDs in ways that violate this assumption. Instead of crashing the
    process we just reset the seq to zero and log a warning as was done in
    the other instances when we have mismatches in the epoch history.
---
 src/couch/src/couch_db.erl | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl
index ab38eb8..4a2d8ef 100644
--- a/src/couch/src/couch_db.erl
+++ b/src/couch/src/couch_db.erl
@@ -1560,7 +1560,14 @@ calculate_start_seq(Db, _Node, {Seq, Uuid, EpochNode}) ->
 calculate_start_seq(Db, _Node, {replace, OriginalNode, Uuid, Seq}) ->
     case is_prefix(Uuid, couch_db:get_uuid(Db)) of
         true ->
-            start_seq(get_epochs(Db), OriginalNode, Seq);
+            try
+                start_seq(get_epochs(Db), OriginalNode, Seq)
+            catch throw:epoch_mismatch ->
+                couch_log:warning("~p start_seq duplicate uuid on node: ~p "
+                    "db: ~p, seq: ~p, uuid: ~p, epoch_node: ~p",
+                    [?MODULE, node(), Db#db.name, Seq, Uuid, OriginalNode]),
+                0
+            end;
         false ->
             {replace, OriginalNode, Uuid, Seq}
     end.
@@ -1608,7 +1615,7 @@ start_seq([{_, NewSeq}, {OrigNode, _} | _], OrigNode, Seq) when Seq > NewSeq ->
 start_seq([_ | Rest], OrigNode, Seq) ->
     start_seq(Rest, OrigNode, Seq);
 start_seq([], OrigNode, Seq) ->
-    erlang:error({epoch_mismatch, OrigNode, Seq}).
+    throw(epoch_mismatch).
 
 
 fold_docs(Db, UserFun, UserAcc) ->