You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2019/10/30 18:32:50 UTC

[couchdb] branch prototype/fdb-layer-abandon-indexer-jobs created (now ecbf89d)

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a change to branch prototype/fdb-layer-abandon-indexer-jobs
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at ecbf89d  Abandon a view job if the db or ddoc is deleted

This branch includes the following new commits:

     new ecbf89d  Abandon a view job if the db or ddoc is deleted

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: Abandon a view job if the db or ddoc is deleted

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch prototype/fdb-layer-abandon-indexer-jobs
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit ecbf89d1e74b9b4252ead10fe3c20890821f152e
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Wed Oct 30 13:32:01 2019 -0500

    Abandon a view job if the db or ddoc is deleted
    
    If we don't explicitly bail out of running the job it will loop
    indefinitely in the couch_jobs retry logic.
---
 src/couch_views/src/couch_views_indexer.erl | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/couch_views/src/couch_views_indexer.erl b/src/couch_views/src/couch_views_indexer.erl
index 55ce063..7c05c1d 100644
--- a/src/couch_views/src/couch_views_indexer.erl
+++ b/src/couch_views/src/couch_views_indexer.erl
@@ -42,8 +42,27 @@ init() ->
         <<"sig">> := JobSig
     } = Data,
 
-    {ok, Db} = fabric2_db:open(DbName, [?ADMIN_CTX]),
-    {ok, DDoc} = fabric2_db:open_doc(Db, DDocId),
+    {ok, Db} = try
+        fabric2_db:open(DbName, [?ADMIN_CTX])
+    catch error:database_does_not_exist ->
+        couch_jobs:finish(undefined, Job, Data#{
+            error => db_deleted,
+            reason => "Database was deleted"
+        }),
+        exit(normal)
+    end,
+
+    {ok, DDoc} = case fabric2_db:open_doc(Db, DDocId) of
+        {ok, DDoc0} ->
+            {ok, DDoc0};
+        {not_found, _} ->
+            couch_jobs:finish(undefined, Job, Data#{
+                error => ddoc_deleted,
+                reason => "Design document was deleted"
+            }),
+            exit(normal)
+    end,
+
     {ok, Mrst} = couch_views_util:ddoc_to_mrst(DbName, DDoc),
     HexSig = fabric2_util:to_hex(Mrst#mrst.sig),