fix(dsrepl): trigger "last-resort" pending transitions handler when idle

This is a hack to work around the unintended issues causing shard
allocator to become idle even when there are pending transitions.
This commit is contained in:
Andrew Mayorov 2024-05-23 14:54:01 +02:00
parent 839b143fc4
commit ba6382adae
No known key found for this signature in database
GPG Key ID: 2837C62ACFBFED5D
1 changed files with 8 additions and 5 deletions

View File

@ -41,6 +41,7 @@
-define(shard_meta(DB, SHARD), {?MODULE, DB, SHARD}).
-define(ALLOCATE_RETRY_TIMEOUT, 1_000).
-define(TRIGGER_PENDING_TIMEOUT, 60_000).
-define(TRANS_RETRY_TIMEOUT, 5_000).
-define(CRASH_RETRY_DELAY, 20_000).
@ -106,7 +107,7 @@ handle_call(_Call, _From, State) ->
-spec handle_cast(_Cast, state()) -> {noreply, state()}.
handle_cast(#trigger_transitions{}, State) ->
{noreply, handle_pending_transitions(State)};
{noreply, handle_pending_transitions(State), ?TRIGGER_PENDING_TIMEOUT};
handle_cast(_Cast, State) ->
{noreply, State}.
@ -118,13 +119,15 @@ handle_cast(_Cast, State) ->
handle_info({timeout, _TRef, allocate}, State) ->
{noreply, handle_allocate_shards(State)};
handle_info({changed, {shard, DB, Shard}}, State = #{db := DB}) ->
{noreply, handle_shard_changed(Shard, State)};
{noreply, handle_shard_changed(Shard, State), ?TRIGGER_PENDING_TIMEOUT};
handle_info({changed, _}, State) ->
{noreply, State};
{noreply, State, ?TRIGGER_PENDING_TIMEOUT};
handle_info({'EXIT', Pid, Reason}, State) ->
{noreply, handle_exit(Pid, Reason, State)};
{noreply, handle_exit(Pid, Reason, State), ?TRIGGER_PENDING_TIMEOUT};
handle_info(timeout, State) ->
{noreply, handle_pending_transitions(State), ?TRIGGER_PENDING_TIMEOUT};
handle_info(_Info, State) ->
{noreply, State}.
{noreply, State, ?TRIGGER_PENDING_TIMEOUT}.
-spec terminate(_Reason, state()) -> _Ok.
terminate(_Reason, State = #{db := DB, shards := Shards}) ->