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/08/20 16:19:13 UTC
(couchdb) branch dont-use-timeouts-for-delayed-init-in-doc-processor created (now 38d0087e0)
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a change to branch dont-use-timeouts-for-delayed-init-in-doc-processor
in repository https://gitbox.apache.org/repos/asf/couchdb.git
at 38d0087e0 Use an explicit message for replicator doc processor delayed init
This branch includes the following new commits:
new 38d0087e0 Use an explicit message for replicator doc processor delayed init
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: Use an explicit message for replicator doc processor delayed init
Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch dont-use-timeouts-for-delayed-init-in-doc-processor
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 38d0087e022fafb6e4f121ddad9ddf845aeb2532
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Tue Aug 20 12:14:26 2024 -0400
Use an explicit message for replicator doc processor delayed init
Previously we used the gen_server timeout mechanism. If the user sets a short
interval value then the periodic membership check message could be delivered
first and reset the scheduled timeout timer. When that happens the scanner and
shard monitor won't start.
To fix it, do not rely on the timeouts, and instead use an explicit message.
That should ensure dalyed init will always run.
---
src/couch_replicator/src/couch_replicator_doc_processor.erl | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/couch_replicator/src/couch_replicator_doc_processor.erl b/src/couch_replicator/src/couch_replicator_doc_processor.erl
index 286076195..5a92c12ff 100644
--- a/src/couch_replicator/src/couch_replicator_doc_processor.erl
+++ b/src/couch_replicator/src/couch_replicator_doc_processor.erl
@@ -221,8 +221,8 @@ init([]) ->
{read_concurrency, true},
{write_concurrency, true}
]),
- StartDelayMSec = start_delay_msec(),
- {ok, schedule_membership_timer(#st{}), StartDelayMSec}.
+ erlang:send_after(start_delay_msec(), self(), delayed_init),
+ {ok, schedule_membership_timer(#st{})}.
handle_call({updated, Id, Rep, Filter, Owner}, _From, #st{} = St) ->
ok = updated_doc(Id, Rep, Filter, Owner),
@@ -242,7 +242,7 @@ handle_call(get_docs, _From, #st{} = St) ->
handle_cast(Msg, #st{} = St) ->
{stop, {error, unexpected_message, Msg}, St}.
-handle_info(timeout, #st{} = St) ->
+handle_info(delayed_init, #st{} = St) ->
{noreply, start_scanner(St)};
handle_info({'DOWN', _, _, _, #doc_worker_result{} = WRes}, #st{} = St) ->
#doc_worker_result{id = Id, wref = Ref, result = Res} = WRes,