summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2012-10-16 13:36:28 +0100
committerSimon MacMullen <simon@rabbitmq.com>2012-10-16 13:36:28 +0100
commit0fef7a0ecc69193712706e8b325d6ed6d7fb8fb5 (patch)
tree5b54741ba33d72ebda8d26d8cc77c19778e0dd78
parentfa3ab5eac41ec0d00eeed03ee2e841d6eee34a1c (diff)
downloadrabbitmq-server-git-0fef7a0ecc69193712706e8b325d6ed6d7fb8fb5.tar.gz
Make sure we don't stomp on GMPids if a slave manages to get to Mnesia before us.
-rw-r--r--src/rabbit_mirror_queue_master.erl9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/rabbit_mirror_queue_master.erl b/src/rabbit_mirror_queue_master.erl
index e6638b011b..ce0d8d3179 100644
--- a/src/rabbit_mirror_queue_master.erl
+++ b/src/rabbit_mirror_queue_master.erl
@@ -97,14 +97,17 @@ init(Q = #amqqueue{name = QName}, Recover, AsyncCallback) ->
ok = gm:broadcast(GM, {depth, BQ:depth(BQS)}),
State.
-init_with_existing_bq(Q, BQ, BQS) ->
+init_with_existing_bq(Q = #amqqueue{name = QName}, BQ, BQS) ->
{ok, CPid} = rabbit_mirror_queue_coordinator:start_link(
Q, undefined, sender_death_fun(), depth_fun()),
GM = rabbit_mirror_queue_coordinator:get_gm(CPid),
- Q1 = Q#amqqueue{gm_pids = [{GM, self()}]},
+ Self = self(),
ok = rabbit_misc:execute_mnesia_transaction(
fun () ->
- ok = rabbit_amqqueue:store_queue(Q1)
+ [Q1 = #amqqueue{gm_pids = GMPids}]
+ = mnesia:read({rabbit_queue, QName}),
+ Q2 = Q1#amqqueue{gm_pids = [{GM, Self} | GMPids]},
+ ok = rabbit_amqqueue:store_queue(Q2)
end),
#state { gm = GM,
coordinator = CPid,