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

vatamane pushed a commit to branch fix-dreyfus-purgeseq-tracking
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 2851972f8b05400f74fab8f8eb84d73a84e8bd5e
Author: Nick Vatamaniuc <[email protected]>
AuthorDate: Mon Mar 9 16:52:22 2026 -0400

    Don't use db handle after closing in dreyfus_index
    
    Make sure we call `maybe_create_local_purge_doc(Db, Pid, Index)` with the 
still
    opened `Db` not after we close it.
---
 src/dreyfus/src/dreyfus_index.erl | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/dreyfus/src/dreyfus_index.erl 
b/src/dreyfus/src/dreyfus_index.erl
index 5295a0065..1ef371d1d 100644
--- a/src/dreyfus/src/dreyfus_index.erl
+++ b/src/dreyfus/src/dreyfus_index.erl
@@ -116,14 +116,13 @@ init({DbName, Index}) ->
                 index = Index#index{current_seq = Seq, dbname = DbName},
                 index_pid = Pid
             },
-            case couch_db:open_int(DbName, []) of
-                {ok, Db} ->
-                    try
-                        couch_db:monitor(Db)
-                    after
-                        couch_db:close(Db)
-                    end,
-                    dreyfus_util:maybe_create_local_purge_doc(Db, Pid, Index),
+            Resp = couch_util:with_db(DbName, fun(Db) ->
+                couch_db:monitor(Db),
+                dreyfus_util:maybe_create_local_purge_doc(Db, Pid, Index),
+                ok
+            end),
+            case Resp of
+                ok ->
                     proc_lib:init_ack({ok, self()}),
                     gen_server:enter_loop(?MODULE, [], State);
                 Error ->

Reply via email to