summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul J. Davis <paul.joseph.davis@gmail.com>2019-05-07 11:59:11 -0500
committerPaul J. Davis <paul.joseph.davis@gmail.com>2019-05-07 11:59:11 -0500
commit54aebc745d807eec9a12900a138333fb121978e0 (patch)
tree44276f8195aeca693b996f7e2f60a84a0ba74fe1
parentaf26397f477e87228cfebd0c8fc583561daaf2e4 (diff)
downloadcouchdb-fix-epoch-mismatch-error.tar.gz
Fix epoch mismatch errorsfix-epoch-mismatch-error
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.
-rw-r--r--src/couch/src/couch_db.erl11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl
index ab38eb895..4a2d8ef37 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) ->