William Yang 1 год назад
Родитель
Сommit
9aaabb044b

+ 4 - 3
apps/emqx_ds_builtin_local/src/emqx_ds_builtin_local_meta_worker.erl

@@ -51,7 +51,7 @@ start_link(DB) ->
 init([DB]) ->
     process_flag(trap_exit, true),
     S = #s{db = DB},
-    self() ! tick,
+    self() ! {?MODULE, tick},
     {ok, S}.
 
 handle_call(_Call, _From, S) ->
@@ -60,7 +60,7 @@ handle_call(_Call, _From, S) ->
 handle_cast(_Cast, S) ->
     {noreply, S}.
 
-handle_info(tick, S = #s{db = DB}) ->
+handle_info({?MODULE, tick}, S = #s{db = DB}) ->
     Shards = emqx_ds_builtin_local_meta:shards(DB),
     [tick(DB, Shard) || Shard <- Shards],
     erlang:send_after(100, self(), tick),
@@ -85,7 +85,8 @@ tick(DB, Shard) ->
         erlang:system_time(microsecond), emqx_ds_builtin_local_meta:current_timestamp(ShardId) + 1
     ),
     emqx_ds_builtin_local_meta:set_current_timestamp(ShardId, Now),
-    Events = emqx_ds_storage_layer:handle_event(ShardId, Now, tick),
+    %% @TODO ????
+    Events = emqx_ds_storage_layer:handle_event(ShardId, Now, {?MODULE, tick}),
     handle_events(ShardId, Now, Events).
 
 handle_events(_ShardId, _Now, []) ->

+ 3 - 1
apps/emqx_ds_builtin_raft/src/emqx_ds_replication_layer.erl

@@ -1085,7 +1085,7 @@ tick(TimeMs, #{db_shard := DBShard = {DB, Shard}, latest := Latest}) ->
     %% Leader = emqx_ds_replication_layer_shard:lookup_leader(DB, Shard),
     {Timestamp, _} = ensure_monotonic_timestamp(timestamp_to_timeus(TimeMs), Latest),
     ?tp(emqx_ds_replication_layer_tick, #{db => DB, shard => Shard, timestamp => Timestamp}),
-    handle_custom_event(DBShard, Timestamp, tick).
+    handle_custom_event(DBShard, Timestamp, ra_tick).
 
 assign_timestamps(true, Latest0, [Message0 = #message{} | Rest], Acc, N, Sz) ->
     case emqx_message:timestamp(Message0, microsecond) of
@@ -1153,6 +1153,8 @@ update_iterator(ShardId, OldIter, DSKey) ->
             Err
     end.
 
+handle_custom_event(_DBShard, _Latest, ra_tick) ->
+    [];
 handle_custom_event(DBShard, Latest, Event) ->
     try
         Events = emqx_ds_storage_layer:handle_event(DBShard, Latest, Event),