diff options
| author | Michael Klishin <mklishin@pivotal.io> | 2016-11-28 15:28:57 +0300 |
|---|---|---|
| committer | Michael Klishin <mklishin@pivotal.io> | 2016-11-28 15:28:57 +0300 |
| commit | 5f04225397fd7f752ab83f8dbf3c2a56ba7a455d (patch) | |
| tree | bc60c894ec321de1de92fde6c8ae808ac40791f5 | |
| parent | e184cb08323a7ff14706aaefd033a0ff92dce2e5 (diff) | |
| download | rabbitmq-server-git-5f04225397fd7f752ab83f8dbf3c2a56ba7a455d.tar.gz | |
Make it possible to disable background GC
and make the interval configurable via config file.
Kudos to Kyle O'Donnell and his team for contributing
a patch that was included with minor modifications:
https://groups.google.com/forum/#!topic/rabbitmq-users/gdqLpdWbop0.
Fixes #1026.
| -rw-r--r-- | src/background_gc.erl | 21 | ||||
| -rw-r--r-- | src/rabbit.app.src | 4 |
2 files changed, 18 insertions, 7 deletions
diff --git a/src/background_gc.erl b/src/background_gc.erl index 2986f356f5..835eaef4df 100644 --- a/src/background_gc.erl +++ b/src/background_gc.erl @@ -25,7 +25,6 @@ terminate/2, code_change/3]). -define(MAX_RATIO, 0.01). --define(IDEAL_INTERVAL, 60000). -define(MAX_INTERVAL, 240000). -record(state, {last_interval}). @@ -45,7 +44,9 @@ run() -> gen_server2:cast(?MODULE, run). %%---------------------------------------------------------------------------- -init([]) -> {ok, interval_gc(#state{last_interval = ?IDEAL_INTERVAL})}. +init([]) -> + {ok, IdealInterval} = application:get_env(rabbit, background_gc_target_interval), + {ok, interval_gc(#state{last_interval = IdealInterval})}. handle_call(Msg, _From, State) -> {stop, {unexpected_call, Msg}, {unexpected_call, Msg}, State}. @@ -65,14 +66,22 @@ terminate(_Reason, State) -> State. %%---------------------------------------------------------------------------- interval_gc(State = #state{last_interval = LastInterval}) -> + {ok, IdealInterval} = application:get_env(rabbit, background_gc_target_interval), {ok, Interval} = rabbit_misc:interval_operation( {?MODULE, gc, []}, - ?MAX_RATIO, ?MAX_INTERVAL, ?IDEAL_INTERVAL, LastInterval), + ?MAX_RATIO, ?MAX_INTERVAL, IdealInterval, LastInterval), erlang:send_after(Interval, self(), run), State#state{last_interval = Interval}. gc() -> - [garbage_collect(P) || P <- processes(), - {status, waiting} == process_info(P, status)], - garbage_collect(), %% since we will never be waiting... + Enabled = rabbit_misc:get_env(rabbit, background_gc_enabled, true), + case Enabled of + true -> + [garbage_collect(P) || P <- processes(), + {status, waiting} == process_info(P, status)], + %% since we will never be waiting... + garbage_collect(); + false -> + ok + end, ok. diff --git a/src/rabbit.app.src b/src/rabbit.app.src index dd38ad4072..9c30876c1d 100644 --- a/src/rabbit.app.src +++ b/src/rabbit.app.src @@ -107,5 +107,7 @@ {passphrase, undefined} ]}, %% rabbitmq-server-973 - {lazy_queue_explicit_gc_run_operation_threshold, 250} + {lazy_queue_explicit_gc_run_operation_threshold, 250}, + {background_gc_enabled, true}, + {background_gc_target_interval, 60000} ]}]}. |
