jiangphcn closed pull request #1568: Log error when changes forced to rewind to 
beginning
URL: https://github.com/apache/couchdb/pull/1568
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl
index 8e932b2edb..55664e9649 100644
--- a/src/couch/src/couch_db.erl
+++ b/src/couch/src/couch_db.erl
@@ -1448,9 +1448,17 @@ calculate_start_seq(Db, _Node, {Seq, Uuid, EpochNode}) ->
         true ->
             case is_owner(EpochNode, Seq, get_epochs(Db)) of
                 true -> Seq;
-                false -> 0
+                false ->
+                    couch_log:warning("~p calculate_start_seq not owner "
+                        "db: ~p, seq: ~p, uuid: ~p, epoch_node: ~p, epochs: 
~p",
+                        [?MODULE, Db#db.name, Seq, Uuid, EpochNode,
+                            get_epochs(Db)]),
+                    0
             end;
         false ->
+            couch_log:warning("~p calculate_start_seq uuid prefix mismatch "
+                "db: ~p, seq: ~p, uuid: ~p, epoch_node: ~p",
+                [?MODULE, Db#db.name, Seq, Uuid, EpochNode]),
             %% The file was rebuilt, most likely in a different
             %% order, so rewind.
             0
@@ -1882,6 +1890,7 @@ calculate_start_seq_test_() ->
 setup_start_seq() ->
     meck:new(couch_db_engine, [passthrough]),
     meck:expect(couch_db_engine, get_uuid, fun(_) -> <<"foo">> end),
+    ok = meck:expect(couch_log, warning, 2, ok),
     Epochs = [
         {node2, 10},
         {node1, 1}
diff --git a/src/fabric/src/fabric_view_changes.erl 
b/src/fabric/src/fabric_view_changes.erl
index 37397447bb..7288f1aa51 100644
--- a/src/fabric/src/fabric_view_changes.erl
+++ b/src/fabric/src/fabric_view_changes.erl
@@ -456,11 +456,13 @@ do_unpack_seqs(Opaque, DbName) ->
     end.
 
 
-get_old_seq(#shard{range=R}, SinceSeqs) ->
+get_old_seq(#shard{range=R}=Shard, SinceSeqs) ->
     case lists:keyfind(R, 2, SinceSeqs) of
-        {_Node, R, Seq} when is_number(Seq) ->
+        {Node, R, Seq} when is_number(Seq) ->
             % Unfortunately we don't have access to the db
             % uuid so we can't set a replacememnt here.
+            couch_log:warning("~p get_old_seq missing uuid "
+                "node: ~p, range: ~p, seq: ~p", [?MODULE, Node, R, Seq]),
             0;
         {Node, R, {Seq, Uuid}} ->
             % This update seq is using the old format that
@@ -471,7 +473,9 @@ get_old_seq(#shard{range=R}, SinceSeqs) ->
             % This is the newest sequence format that we
             % can use for replacement.
             {Seq, Uuid, EpochNode};
-        _ ->
+        Error ->
+            couch_log:warning("~p get_old_seq error: ~p, shard: ~p, seqs: ~p",
+                [?MODULE, Error, Shard, SinceSeqs]),
             0
     end.
 
diff --git a/src/mem3/src/mem3_rep.erl b/src/mem3/src/mem3_rep.erl
index 03178cf5ce..5920f3bd4a 100644
--- a/src/mem3/src/mem3_rep.erl
+++ b/src/mem3/src/mem3_rep.erl
@@ -173,6 +173,9 @@ find_source_seq(SrcDb, TgtNode, TgtUUIDPrefix, TgtSeq) ->
         SrcNode = atom_to_binary(node(), utf8),
         find_source_seq_int(Doc, SrcNode, TgtNode, TgtUUID, TgtSeq);
     {not_found, _} ->
+        couch_log:warning("~p find_source_seq repl doc not_found "
+            "src_db: ~p, tgt_node: ~p, tgt_uuid_prefix: ~p, tgt_seq: ~p",
+            [?MODULE, SrcDb, TgtNode, TgtUUIDPrefix, TgtSeq]),
         0
     end.
 
@@ -202,6 +205,10 @@ find_source_seq_int(#doc{body={Props}}, SrcNode0, 
TgtNode0, TgtUUID, TgtSeq) ->
         [{Entry} | _] ->
             couch_util:get_value(<<"source_seq">>, Entry);
         [] ->
+            couch_log:warning("~p find_source_seq_int nil useable history "
+                "src_node: ~p, tgt_node: ~p, tgt_uuid: ~p, tgt_seq: ~p, "
+                "src_history: ~p",
+                [?MODULE, SrcNode, TgtNode, TgtUUID, TgtSeq, SrcHistory]),
             0
     end.
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to