Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix case clause error in replicator _scheduler/docs response #5008

Merged
merged 1 commit into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
nickva committed Mar 17, 2024
commit 6aa04d06ade041744bc0fefafb464dde075d4ee8
4 changes: 3 additions & 1 deletion src/couch_replicator/src/couch_replicator_fabric.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/couch_replicator/src/couch_replicator_fabric_rpc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ t_scheduler_docs_total_rows({_Ctx, {RepDb, Source, Target}}) ->
case req(get, SchedulerDocsUrl) of
{200, #{<<"docs">> := [_ | _]} = Decoded} ->
Decoded;
{_, #{<<"error">> := Error, <<"reason">> := Reason}} ->
pgj marked this conversation as resolved.
Show resolved Hide resolved
?debugVal(Error, 100),
?debugVal(binary_to_list(Reason), 100);
{_, #{}} ->
{200, #{<<"docs">> := []}} ->
wait
end
end,
Expand Down