You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2020/08/19 10:54:04 UTC

[couchdb] branch 2.3.1+jiffy+epoch created (now 4aed3c0)

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

jan pushed a change to branch 2.3.1+jiffy+epoch
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at 4aed3c0  Fix epoch mismatch errors (#2027)

This branch includes the following new commits:

     new 8ff673a  fix: backport 3.x jiffy fixes
     new 4aed3c0  Fix epoch mismatch errors (#2027)

The 2 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] 02/02: Fix epoch mismatch errors (#2027)

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

jan pushed a commit to branch 2.3.1+jiffy+epoch
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 4aed3c0582f2cf5edeff8e664bac8bace5a6e4f7
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Tue May 7 15:06:06 2019 -0500

    Fix epoch mismatch errors (#2027)
    
    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 | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl
index 0ae164d..2cbc297 100644
--- a/src/couch/src/couch_db.erl
+++ b/src/couch/src/couch_db.erl
@@ -1491,7 +1491,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.
@@ -1538,8 +1545,8 @@ start_seq([{_, NewSeq}, {OrigNode, _} | _], OrigNode, Seq) when Seq > NewSeq ->
     NewSeq;
 start_seq([_ | Rest], OrigNode, Seq) ->
     start_seq(Rest, OrigNode, Seq);
-start_seq([], OrigNode, Seq) ->
-    erlang:error({epoch_mismatch, OrigNode, Seq}).
+start_seq([], _OrigNode, _Seq) ->
+    throw(epoch_mismatch).
 
 
 fold_docs(Db, UserFun, UserAcc) ->
@@ -1917,7 +1924,8 @@ calculate_start_seq_test_() ->
             t_calculate_start_seq_uuid_mismatch(),
             t_calculate_start_seq_is_owner(),
             t_calculate_start_seq_not_owner(),
-            t_calculate_start_seq_raw()
+            t_calculate_start_seq_raw(),
+            t_calculate_start_seq_epoch_mismatch()
         ]
     }.
 
@@ -1962,6 +1970,14 @@ t_calculate_start_seq_raw() ->
         ?assertEqual(13, Seq)
     end).
 
+t_calculate_start_seq_epoch_mismatch() ->
+    ?_test(begin
+        Db = test_util:fake_db([]),
+        SeqIn = {replace, not_this_node, get_uuid(Db), 42},
+        Seq = calculate_start_seq(Db, node1, SeqIn),
+        ?assertEqual(0, Seq)
+    end).
+
 is_owner_test() ->
     ?assertNot(is_owner(foo, 1, [])),
     ?assertNot(is_owner(foo, 1, [{foo, 1}])),


[couchdb] 01/02: fix: backport 3.x jiffy fixes

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

jan pushed a commit to branch 2.3.1+jiffy+epoch
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 8ff673a3c7b3948c56f154a68829b404150e8b35
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Wed Aug 19 12:47:17 2020 +0200

    fix: backport 3.x jiffy fixes
---
 rebar.config.script | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rebar.config.script b/rebar.config.script
index ef16a32..3a300c3 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -101,7 +101,7 @@ DepDescs = [
 {folsom,           "folsom",           {tag, "CouchDB-0.8.2"}},
 {hyper,            "hyper",            {tag, "CouchDB-2.2.0-4"}},
 {ibrowse,          "ibrowse",          {tag, "CouchDB-4.0.1"}},
-{jiffy,            "jiffy",            {tag, "CouchDB-0.14.11-2"}},
+{jiffy,            "jiffy",            {tag, "CouchDB-1.0.4-1"}},
 {mochiweb,         "mochiweb",         {tag, "v2.19.0"}},
 {meck,             "meck",             {tag, "0.8.8"}}
 ],