Merge bug26110
This commit is contained in:
		
						commit
						390f67f2bc
					
				| 
						 | 
					@ -137,7 +137,7 @@
 | 
				
			||||||
          %% {queue/channel/connection}
 | 
					          %% {queue/channel/connection}
 | 
				
			||||||
          old_stats,
 | 
					          old_stats,
 | 
				
			||||||
          gc_timer,
 | 
					          gc_timer,
 | 
				
			||||||
          gc_continuation,
 | 
					          gc_next_key,
 | 
				
			||||||
          lookups,
 | 
					          lookups,
 | 
				
			||||||
          interval,
 | 
					          interval,
 | 
				
			||||||
          event_refresh_ref}).
 | 
					          event_refresh_ref}).
 | 
				
			||||||
| 
						 | 
					@ -1042,25 +1042,29 @@ augment_connection_pid(Pid, #state{tables = Tables}) ->
 | 
				
			||||||
%% Internal, event-GCing
 | 
					%% Internal, event-GCing
 | 
				
			||||||
%%----------------------------------------------------------------------------
 | 
					%%----------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
gc_batch(State = #state{aggregated_stats = ETS,
 | 
					gc_batch(State = #state{aggregated_stats = ETS}) ->
 | 
				
			||||||
                        gc_continuation = Continuation}) ->
 | 
					    {ok, Policies} = application:get_env(
 | 
				
			||||||
    Match = case Continuation of
 | 
					                       rabbitmq_management, sample_retention_policies),
 | 
				
			||||||
                undefined -> Size = ets:info(ETS, size),
 | 
					    Rows = erlang:max(?GC_MIN_ROWS,
 | 
				
			||||||
                             Rows = lists:max([?GC_MIN_ROWS,
 | 
					                      round(?GC_MIN_RATIO * ets:info(ETS, size))),
 | 
				
			||||||
                                               round(?GC_MIN_RATIO * Size)]),
 | 
					    gc_batch(Rows, Policies, State).
 | 
				
			||||||
                             ets:match(ETS, '$1', Rows);
 | 
					
 | 
				
			||||||
                _         -> ets:match(Continuation)
 | 
					gc_batch(0, _Policies, State) ->
 | 
				
			||||||
            end,
 | 
					    State;
 | 
				
			||||||
    case Match of
 | 
					gc_batch(Rows, Policies, State = #state{aggregated_stats = ETS,
 | 
				
			||||||
        {Matches, Continuation1} ->
 | 
					                         gc_next_key      = Key0}) ->
 | 
				
			||||||
            {ok, Policies} = application:get_env(
 | 
					    Key = case Key0 of
 | 
				
			||||||
                               rabbitmq_management, sample_retention_policies),
 | 
					              undefined -> ets:first(ETS);
 | 
				
			||||||
            Now = floor(erlang:now(), State),
 | 
					              _         -> ets:next(ETS, Key0)
 | 
				
			||||||
            [gc(Key, Stats, Policies, Now, ETS) || [{Key, Stats}] <- Matches],
 | 
					          end,
 | 
				
			||||||
            State#state{gc_continuation = Continuation1};
 | 
					    Key1 = case Key of
 | 
				
			||||||
        '$end_of_table' ->
 | 
					               '$end_of_table' -> undefined;
 | 
				
			||||||
            State#state{gc_continuation = undefined}
 | 
					               _               -> Now = floor(erlang:now(), State),
 | 
				
			||||||
    end.
 | 
					                                  Stats = ets:lookup_element(ETS, Key, 2),
 | 
				
			||||||
 | 
					                                  gc(Key, Stats, Policies, Now, ETS),
 | 
				
			||||||
 | 
					                                  Key
 | 
				
			||||||
 | 
					           end,
 | 
				
			||||||
 | 
					    gc_batch(Rows - 1, Policies, State#state{gc_next_key = Key1}).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
gc({{Type, Id}, Key}, Stats, Policies, Now, ETS) ->
 | 
					gc({{Type, Id}, Key}, Stats, Policies, Now, ETS) ->
 | 
				
			||||||
    Policy = pget(retention_policy(Type), Policies),
 | 
					    Policy = pget(retention_policy(Type), Policies),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue