fix(cluster-link): adapt heartbeat / reincarnation handling to new API

This commit is contained in:
Andrew Mayorov 2024-05-20 16:20:02 +02:00 committed by Serge Tupchii
parent 43d114546c
commit 45eda4f3b9
1 changed files with 7 additions and 6 deletions

View File

@ -229,10 +229,11 @@ actor_apply_operation(
State; State;
actor_apply_operation( actor_apply_operation(
heartbeat, heartbeat,
State = #state{actor = Actor, incarnation = Incarnation}, State = #state{cluster = Cluster, actor = Actor, incarnation = Incarnation},
_Env = #{timestamp := Now} _Env = #{timestamp := Now}
) -> ) ->
ok = transaction(fun ?MODULE:mnesia_actor_heartbeat/3, [Actor, Incarnation, Now]), ActorID = ?ACTOR_ID(Cluster, Actor),
ok = transaction(fun ?MODULE:mnesia_actor_heartbeat/3, [ActorID, Incarnation, Now]),
State. State.
apply_actor_operation(ActorID, Incarnation, Entry, OpName, Lane) -> apply_actor_operation(ActorID, Incarnation, Entry, OpName, Lane) ->
@ -303,14 +304,14 @@ select_cluster_lanes(Cluster) ->
MS = [{#actor{id = {Cluster, '_'}, lane = '$1', _ = '_'}, [], ['$1']}], MS = [{#actor{id = {Cluster, '_'}, lane = '$1', _ = '_'}, [], ['$1']}],
mnesia:select(?EXTROUTE_ACTOR_TAB, MS, write). mnesia:select(?EXTROUTE_ACTOR_TAB, MS, write).
mnesia_actor_heartbeat(Actor, Incarnation, TS) -> mnesia_actor_heartbeat(ActorID, Incarnation, TS) ->
case mnesia:read(?EXTROUTE_ACTOR_TAB, Actor, write) of case mnesia:read(?EXTROUTE_ACTOR_TAB, ActorID, write) of
[#actor{incarnation = Incarnation} = Rec] -> [#actor{incarnation = Incarnation} = Rec] ->
ok = mnesia:write(?EXTROUTE_ACTOR_TAB, Rec#actor{until = bump_actor_ttl(TS)}, write); ok = mnesia:write(?EXTROUTE_ACTOR_TAB, Rec#actor{until = bump_actor_ttl(TS)}, write);
[#actor{incarnation = Outdated}] -> [#actor{incarnation = Outdated}] ->
mnesia:abort({outdated_incarnation_actor, Actor, Incarnation, Outdated}); mnesia:abort({outdated_incarnation_actor, ActorID, Incarnation, Outdated});
[] -> [] ->
mnesia:abort({nonexistent_actor, Actor}) mnesia:abort({nonexistent_actor, ActorID})
end. end.
clean_incarnation(Rec) -> clean_incarnation(Rec) ->