diff options
author | Nick Vatamaniuc <vatamane@apache.org> | 2020-09-30 15:41:25 -0400 |
---|---|---|
committer | Nick Vatamaniuc <nickva@users.noreply.github.com> | 2020-09-30 16:55:20 -0400 |
commit | a07413385b741e044ce9d7aa588c2918faacbebf (patch) | |
tree | b41cdfd72cb7ae562f1e361003909c4fa8ba828e | |
parent | 4a4515e01d82a6f88ecd3a6b61b5beeab6127424 (diff) | |
download | couchdb-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.erl | 4 |
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} |