summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Vatamaniuc <vatamane@apache.org>2020-09-30 15:41:25 -0400
committerNick Vatamaniuc <nickva@users.noreply.github.com>2020-09-30 16:55:20 -0400
commita07413385b741e044ce9d7aa588c2918faacbebf (patch)
treeb41cdfd72cb7ae562f1e361003909c4fa8ba828e
parent4a4515e01d82a6f88ecd3a6b61b5beeab6127424 (diff)
downloadcouchdb-a07413385b741e044ce9d7aa588c2918faacbebf.tar.gz
Fix transient replication job state wait logic
Make sure to handle both `finished` and `pending` states when waiting for a transient jobs. A transient job will go to the `failed` state if it cannot fetch the filter from the source endpoint. For completeness, we also account for `pending` states in there in the remote chance the job get rescheduled again.
-rw-r--r--src/couch_replicator/src/couch_replicator_jobs.erl4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/couch_replicator/src/couch_replicator_jobs.erl b/src/couch_replicator/src/couch_replicator_jobs.erl
index a602b0c62..51f441caf 100644
--- a/src/couch_replicator/src/couch_replicator_jobs.erl
+++ b/src/couch_replicator/src/couch_replicator_jobs.erl
@@ -170,12 +170,14 @@ wait_running(JobId) ->
wait_running(JobId, SubId) ->
- case couch_jobs:wait(SubId, running, infinity) of
+ case couch_jobs:wait(SubId, infinity) of
{?REP_JOBS, _, running, #{?STATE := ?ST_PENDING}} ->
wait_running(JobId, SubId);
{?REP_JOBS, _, running, JobData} ->
ok = couch_jobs:unsubscribe(SubId),
{ok, JobData};
+ {?REP_JOBS, _, pending, _} ->
+ wait_running(JobId, SubId);
{?REP_JOBS, _, finished, JobData} ->
ok = couch_jobs:unsubscribe(SubId),
{ok, JobData}