fix(ds): Fix idle event generation in bitfield_lts layout

This commit is contained in:
ieQu1 2024-05-20 15:53:11 +02:00
parent b3ded7edce
commit 29345aaa30
No known key found for this signature in database
GPG Key ID: 488654DF3FED6FDE
3 changed files with 7 additions and 10 deletions

View File

@ -246,7 +246,7 @@ fields(layout_builtin_reference) ->
reference,
#{
'readOnly' => true,
importance => ?IMPORTANCE_HIDDEN
importance => ?IMPORTANCE_LOW
}
)}
].
@ -273,17 +273,12 @@ ds_schema(Options) ->
Options
).
-ifndef(TEST).
builtin_layouts() ->
[ref(layout_builtin_wildcard_optimized)].
-else.
builtin_layouts() ->
%% Reference layout stores everything in one stream, so it's not
%% suitable for production use. However, it's very simple and
%% produces a very predictabale replay order, which can be useful
%% for testing and debugging:
[ref(layout_builtin_wildcard_optimized), ref(layout_builtin_reference)].
-endif.
sc(Type, Meta) -> hoconsc:mk(Type, Meta).

View File

@ -161,7 +161,7 @@
%% GVar used for idle detection:
-define(IDLE_DETECT, idle_detect).
-define(EPOCH(S, TS), (TS bsl S#s.ts_bits)).
-define(EPOCH(S, TS), (TS bsr S#s.ts_offset)).
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
@ -458,7 +458,7 @@ next(
SafeCutoffTime =
case HasCutoff of
true ->
(Now bsr TSOffset) bsl TSOffset;
?EPOCH(Schema, Now) bsl TSOffset;
false ->
1 bsl TSBits - 1
end,
@ -561,13 +561,15 @@ handle_event(_ShardId, State = #s{gvars = Gvars}, Time, tick) ->
LastWrittenTs = 0
end,
case Latch of
false when ?EPOCH(State, Time) > ?EPOCH(State, LastWrittenTs) ->
false when ?EPOCH(State, Time) > ?EPOCH(State, LastWrittenTs) + 1 ->
ets:insert(Gvars, {?IDLE_DETECT, true, LastWrittenTs}),
[dummy_event];
_ ->
[]
end;
handle_event(_ShardId, _Data, _Time, _Event) ->
%% `dummy_event' goes here and does nothing. But it forces update
%% of `Time' in the replication layer.
[].
%%================================================================================

View File

@ -183,7 +183,7 @@ t_rebalance(Config) ->
],
Stream1 = emqx_utils_stream:interleave(
[
{50, Stream0},
{10, Stream0},
emqx_utils_stream:const(add_generation)
],
false