You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2024/11/04 15:29:18 UTC

(couchdb) 01/01: Skip deleted documents in the scanner

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

vatamane pushed a commit to branch not-found-in-scanner
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 4766cd42dd5372290668154f525a1b789b7c0f24
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Mon Nov 4 10:28:05 2024 -0500

    Skip deleted documents in the scanner
    
    They can be deleted while the scanner is running. If that happens the scanner
    would crash and restart but it makes for a noisy mess in the logs.
---
 src/couch_scanner/src/couch_scanner_plugin.erl | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/couch_scanner/src/couch_scanner_plugin.erl b/src/couch_scanner/src/couch_scanner_plugin.erl
index 59dfb919f..18b5efd06 100644
--- a/src/couch_scanner/src/couch_scanner_plugin.erl
+++ b/src/couch_scanner/src/couch_scanner_plugin.erl
@@ -393,12 +393,16 @@ scan_docs_fold(#full_doc_info{id = Id} = FDI, #st{} = St) ->
 scan_doc(#full_doc_info{} = FDI, #st{} = St) ->
     #st{db = Db, callbacks = Cbks, pst = PSt} = St,
     St1 = rate_limit(St, doc),
-    {ok, #doc{} = Doc} = couch_db:open_doc(Db, FDI, [ejson_body]),
-    #{doc := DocCbk} = Cbks,
-    {Go, PSt1} = DocCbk(PSt, Db, Doc),
-    case Go of
-        ok -> {ok, St1#st{pst = PSt1}};
-        stop -> {stop, St1#st{pst = PSt1}}
+    case couch_db:open_doc(Db, FDI, [ejson_body]) of
+        {ok, #doc{} = Doc} ->
+            #{doc := DocCbk} = Cbks,
+            {Go, PSt1} = DocCbk(PSt, Db, Doc),
+            case Go of
+                ok -> {ok, St1#st{pst = PSt1}};
+                stop -> {stop, St1#st{pst = PSt1}}
+            end;
+        {not_found, _} ->
+            {ok, St1}
     end.
 
 maybe_checkpoint(#st{checkpoint_sec = LastCheckpointTSec} = St) ->