summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul J. Davis <paul.joseph.davis@gmail.com>2020-04-09 12:57:51 -0500
committerPaul J. Davis <paul.joseph.davis@gmail.com>2020-04-10 16:30:49 -0500
commit2e5a5566be88036ae6bb8d1f420bd6028f7c6253 (patch)
tree69c32a735ed7495c1cd586dbf9b25a5bda0a0309
parent7aeb54bf6012c234c5806db6f438427c9cb53c4a (diff)
downloadcouchdb-2e5a5566be88036ae6bb8d1f420bd6028f7c6253.tar.gz
Remove jobs on index cleanup
-rw-r--r--src/couch_views/src/couch_views.erl1
-rw-r--r--src/couch_views/src/couch_views_jobs.erl9
2 files changed, 9 insertions, 1 deletions
diff --git a/src/couch_views/src/couch_views.erl b/src/couch_views/src/couch_views.erl
index cc183643b..9d518ebce 100644
--- a/src/couch_views/src/couch_views.erl
+++ b/src/couch_views/src/couch_views.erl
@@ -90,6 +90,7 @@ cleanup_indices(#{} = Db, DDocs) when is_list(DDocs) ->
ExistingSigs = couch_views_fdb:list_signatures(Db),
StaleSigs = ExistingSigs -- ActiveSigs,
lists:foreach(fun(Sig) ->
+ couch_views_jobs:remove(Db, Sig),
couch_views_fdb:clear_index(Db, Sig)
end, StaleSigs).
diff --git a/src/couch_views/src/couch_views_jobs.erl b/src/couch_views/src/couch_views_jobs.erl
index b97e7ce0f..76cc56337 100644
--- a/src/couch_views/src/couch_views_jobs.erl
+++ b/src/couch_views/src/couch_views_jobs.erl
@@ -15,7 +15,8 @@
-export([
set_timeout/0,
build_view/3,
- build_view_async/2
+ build_view_async/2,
+ remove/2
]).
-ifdef(TEST).
@@ -60,6 +61,12 @@ build_view_async(TxDb0, Mrst) ->
{ok, JobId}.
+remove(TxDb, Sig) ->
+ DbName = fabric2_db:name(TxDb),
+ JobId = job_id(DbName, Sig),
+ couch_jobs:remove(TxDb, ?INDEX_JOB_TYPE, JobId).
+
+
ensure_correct_tx(#{tx := undefined} = TxDb) ->
TxDb;