summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2012-11-22 13:10:24 +0000
committerSimon MacMullen <simon@rabbitmq.com>2012-11-22 13:10:24 +0000
commitfbf5b8d0b9795d43e433c745ce414fd2156231ef (patch)
treeb62425791c5146f0176ba1469a1899d606a6d8d9
parentc0524468b1feb9ff7348c8c73d480c2bec875112 (diff)
downloadrabbitmq-server-fbf5b8d0b9795d43e433c745ce414fd2156231ef.tar.gz
Fix a race where we decide on the BQ before writing the #amqqueue{} to Mnesia, then the policy changes and we are therefore not notified. We now only make the initial decision after we can be assured we will be informed of subsequent changes.
-rw-r--r--src/rabbit_amqqueue_process.erl9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index 6af43193..6f8c9305 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -122,11 +122,10 @@ info_keys() -> ?INFO_KEYS.
init(Q) ->
process_flag(trap_exit, true),
-
State = #q{q = Q#amqqueue{pid = self()},
exclusive_consumer = none,
has_had_consumers = false,
- backing_queue = backing_queue_module(Q),
+ backing_queue = undefined,
backing_queue_state = undefined,
active_consumers = queue:new(),
expires = undefined,
@@ -193,7 +192,7 @@ code_change(_OldVsn, State, _Extra) ->
%%----------------------------------------------------------------------------
declare(Recover, From, State = #q{q = Q,
- backing_queue = BQ,
+ backing_queue = undefined,
backing_queue_state = undefined}) ->
case rabbit_amqqueue:internal_declare(Q, Recover =/= new) of
#amqqueue{} = Q1 ->
@@ -205,9 +204,11 @@ declare(Recover, From, State = #q{q = Q,
ok = rabbit_memory_monitor:register(
self(), {rabbit_amqqueue,
set_ram_duration_target, [self()]}),
+ BQ = backing_queue_module(Q1),
BQS = bq_init(BQ, Q, Recover),
recovery_barrier(Recover),
- State1 = process_args(State#q{backing_queue_state = BQS}),
+ State1 = process_args(State#q{backing_queue = BQ,
+ backing_queue_state = BQS}),
rabbit_event:notify(queue_created,
infos(?CREATION_EVENT_KEYS, State1)),
rabbit_event:if_enabled(State1, #q.stats_timer,