Преглед изворни кода

Fix the 'route_batch_delete' config

周子博 пре 7 година
родитељ
комит
5c291ff23e
3 измењених фајлова са 4 додато и 4 уклоњено
  1. 1 1
      etc/emqx.conf
  2. 2 2
      src/emqx_router.erl
  3. 1 1
      test/emqx_router_SUITE.erl

+ 1 - 1
etc/emqx.conf

@@ -1928,7 +1928,7 @@ broker.shared_dispatch_ack_enabled = false
 ## Enable batch clean for deleted routes.
 ## Enable batch clean for deleted routes.
 ##
 ##
 ## Value: Flag
 ## Value: Flag
-broker.route_batch_clean = on
+broker.route_batch_clean = off
 
 
 ##--------------------------------------------------------------------
 ##--------------------------------------------------------------------
 ## System Monitor
 ## System Monitor

+ 2 - 2
src/emqx_router.erl

@@ -137,7 +137,7 @@ pick(Topic) ->
 init([Pool, Id]) ->
 init([Pool, Id]) ->
     rand:seed(exsplus, erlang:timestamp()),
     rand:seed(exsplus, erlang:timestamp()),
     gproc_pool:connect_worker(Pool, {Pool, Id}),
     gproc_pool:connect_worker(Pool, {Pool, Id}),
-    Batch = #batch{enabled = emqx_config:get_env(route_batch_delete, false),
+    Batch = #batch{enabled = emqx_config:get_env(route_batch_clean, false),
                    pending = sets:new()},
                    pending = sets:new()},
     {ok, ensure_batch_timer(#state{pool = Pool, id = Id, batch = Batch})}.
     {ok, ensure_batch_timer(#state{pool = Pool, id = Id, batch = Batch})}.
 
 
@@ -191,7 +191,7 @@ handle_cast(Msg, State) ->
     {noreply, State}.
     {noreply, State}.
 
 
 handle_info({timeout, _TRef, batch_delete}, State = #state{batch = Batch}) ->
 handle_info({timeout, _TRef, batch_delete}, State = #state{batch = Batch}) ->
-    _ = del_direct_routes(Batch#batch.pending),
+    _ = del_direct_routes(sets:to_list(Batch#batch.pending)),
     {noreply, ensure_batch_timer(State#state{batch = ?BATCH(true, sets:new())}), hibernate};
     {noreply, ensure_batch_timer(State#state{batch = ?BATCH(true, sets:new())}), hibernate};
 
 
 handle_info(Info, State) ->
 handle_info(Info, State) ->

+ 1 - 1
test/emqx_router_SUITE.erl

@@ -64,7 +64,7 @@ add_del_route(_) ->
     ?R:del_route(From, <<"a/b/c">>, node()),
     ?R:del_route(From, <<"a/b/c">>, node()),
 
 
     ?R:del_route(From, <<"a/+/b">>, node()),
     ?R:del_route(From, <<"a/+/b">>, node()),
-    timer:sleep(1),
+    timer:sleep(120),
     ?assertEqual([], lists:sort(?R:topics())).
     ?assertEqual([], lists:sort(?R:topics())).
 
 
 match_routes(_) ->
 match_routes(_) ->