You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2024/03/16 07:12:24 UTC
(couchdb) 01/01: Fix case clause error in replicator _scheduler/docs response
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch jenkins-fix-replicator-nil-case-clause
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 360824c660dc39c824d24b7f8a96ab516fd95fa3
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Sat Mar 16 03:03:33 2024 -0400
Fix case clause error in replicator _scheduler/docs response
When a job is completing, there is a period of time when the document isn't
updated yet with the state, and it's also not present in the scheduler ets
table. In that case we return `nil`, but we don't account for that case in the
_scheduler/docs fabric calls.
To fix it, account for `nil` whenever we get the doc state.
---
src/couch_replicator/src/couch_replicator_fabric.erl | 4 +++-
src/couch_replicator/src/couch_replicator_fabric_rpc.erl | 5 ++++-
.../test/eunit/couch_replicator_scheduler_docs_tests.erl | 3 ---
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/couch_replicator/src/couch_replicator_fabric.erl b/src/couch_replicator/src/couch_replicator_fabric.erl
index 9a069fac9..d570d6f77 100644
--- a/src/couch_replicator/src/couch_replicator_fabric.erl
+++ b/src/couch_replicator/src/couch_replicator_fabric.erl
@@ -18,7 +18,6 @@
-include_lib("fabric/include/fabric.hrl").
-include_lib("mem3/include/mem3.hrl").
--include_lib("couch/include/couch_db.hrl").
-include_lib("couch_mrview/include/couch_mrview.hrl").
docs(DbName, Options, QueryArgs, Callback, Acc) ->
@@ -167,6 +166,9 @@ maybe_fetch_and_filter_doc(Id, undecided, State) ->
{ok, {Props} = DocInfo} ->
DocState = couch_util:get_value(state, Props),
couch_replicator_utils:filter_state(DocState, FilterStates, DocInfo);
+ {ok, nil} ->
+ % could have just completed
+ skip;
{error, not_found} ->
% could have been deleted
skip
diff --git a/src/couch_replicator/src/couch_replicator_fabric_rpc.erl b/src/couch_replicator/src/couch_replicator_fabric_rpc.erl
index f6b9b4080..1a3582928 100644
--- a/src/couch_replicator/src/couch_replicator_fabric_rpc.erl
+++ b/src/couch_replicator/src/couch_replicator_fabric_rpc.erl
@@ -17,7 +17,6 @@
]).
-include_lib("fabric/include/fabric.hrl").
--include_lib("couch/include/couch_db.hrl").
-include_lib("couch_mrview/include/couch_mrview.hrl").
docs(DbName, Options, Args0) ->
@@ -80,6 +79,10 @@ rep_doc_state(Shard, Id, {[_ | _]} = Doc, States, HealthThreshold) ->
HealthThreshold
)
of
+ {ok, nil} ->
+ % Could have been just completed. Let the coordinator
+ % try to refetch it.
+ undecided;
{ok, EtsInfo} ->
State = get_doc_state(EtsInfo),
couch_replicator_utils:filter_state(State, States, EtsInfo);
diff --git a/src/couch_replicator/test/eunit/couch_replicator_scheduler_docs_tests.erl b/src/couch_replicator/test/eunit/couch_replicator_scheduler_docs_tests.erl
index e04518b67..7694ddeda 100644
--- a/src/couch_replicator/test/eunit/couch_replicator_scheduler_docs_tests.erl
+++ b/src/couch_replicator/test/eunit/couch_replicator_scheduler_docs_tests.erl
@@ -133,9 +133,6 @@ t_scheduler_docs_total_rows({_Ctx, {RepDb, Source, Target}}) ->
case req(get, SchedulerDocsUrl) of
{200, #{<<"docs">> := [_ | _]} = Decoded} ->
Decoded;
- {_, #{<<"error">> := Error, <<"reason">> := Reason}} ->
- ?debugVal(Error, 100),
- ?debugVal(binary_to_list(Reason), 100);
{_, #{}} ->
wait
end