diff options
| author | Matthew Sackman <matthew@rabbitmq.com> | 2011-03-08 13:24:18 +0000 |
|---|---|---|
| committer | Matthew Sackman <matthew@rabbitmq.com> | 2011-03-08 13:24:18 +0000 |
| commit | f08e57cc08a16a3c31955981838970e4a3b10c74 (patch) | |
| tree | de06c9387f42554c606486b45e3ebdcf7c68bbdc /src | |
| parent | b0bd6c8a98f59e9a1537133dc0d0eaa41f0a87da (diff) | |
| download | rabbitmq-server-git-f08e57cc08a16a3c31955981838970e4a3b10c74.tar.gz | |
Hmm, I'd forgotten than deliver_immediately == false => the msg _isn't_ enqueued
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_mirror_queue_slave.erl | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl index 0aedff59e4..e17eef01ac 100644 --- a/src/rabbit_mirror_queue_slave.erl +++ b/src/rabbit_mirror_queue_slave.erl @@ -119,16 +119,15 @@ init([#amqqueue { name = QueueName } = Q]) -> handle_call({deliver_immediately, Delivery = #delivery {}}, From, State) -> %% Synchronous, "immediate" delivery mode - %% - %% TODO: we cannot reply here because we may not have received - %% this from gm, and indeed the master might die before it - %% receives it. Thus if we are promoted to master at that point - %% then we must reply appropriately. So we're going to have to - %% enqueue it, record that it needs a reply, and then reply either - %% when we get the nod via gm, or, if we're promoted, in the mean - %% time we'll have to figure out something else... Of course, if - %% we've already seen it from gm then we're going to have to reply - %% now. + + %% It is safe to reply 'false' here even if a) we've not seen the + %% msg via gm, or b) the master dies before we receive the msg via + %% gm. In the case of (a), we will eventually receive the msg via + %% gm, and it's only the master's result to the channel that is + %% important. In the case of (b), if the master does die and we do + %% get promoted then at that point we have no consumers, thus + %% 'false' is precisely the correct answer. However, we must be + %% careful to _not_ enqueue the message in this case. gen_server2:reply(From, false), %% master may deliver it, not us noreply(maybe_enqueue_message(Delivery, State)); |
