浏览代码

Merge pull request #13673 from zmstone/0822-fix-trace-respect-user-specified-start-time

fix(trace): respect trace start_at time as is
zmstone 1 年之前
父节点
当前提交
2fc47b979a

+ 1 - 2
apps/emqx/src/emqx_trace/emqx_trace.erl

@@ -651,8 +651,7 @@ to_trace(#{type := Type}, _Rec) ->
 to_trace(#{payload_encode := PayloadEncode} = Trace, Rec) ->
     to_trace(maps:remove(payload_encode, Trace), Rec#?TRACE{payload_encode = PayloadEncode});
 to_trace(#{start_at := StartAt} = Trace, Rec) ->
-    {ok, Sec} = to_system_second(StartAt),
-    to_trace(maps:remove(start_at, Trace), Rec#?TRACE{start_at = Sec});
+    to_trace(maps:remove(start_at, Trace), Rec#?TRACE{start_at = StartAt});
 to_trace(#{end_at := EndAt} = Trace, Rec) ->
     Now = now_second(),
     case to_system_second(EndAt) of

+ 1 - 0
apps/emqx/src/emqx_trace/emqx_trace_dl.erl

@@ -53,6 +53,7 @@ update(Name, Enable) ->
 insert_new_trace(Trace) ->
     case mnesia:read(?TRACE, Trace#?TRACE.name) of
         [] ->
+            %% allow one new trace for each filter in the same second
             #?TRACE{start_at = StartAt, type = Type, filter = Filter} = Trace,
             Match = #?TRACE{_ = '_', start_at = StartAt, type = Type, filter = Filter},
             case mnesia:match_object(?TRACE, Match, read) of

+ 4 - 0
apps/emqx_ds_builtin_raft/test/emqx_ds_replication_SUITE.erl

@@ -1066,6 +1066,10 @@ groups() ->
         {skipstream_lts, TCs}
     ].
 
+init_per_suite(Config) ->
+    application:set_env(kernel, prevent_overlapping_partitions, false),
+    Config.
+
 init_per_group(Group, Config) ->
     LayoutConf =
         case Group of