diff options
| author | kjnilsson <knilsson@pivotal.io> | 2020-10-07 14:34:35 +0100 |
|---|---|---|
| committer | kjnilsson <knilsson@pivotal.io> | 2020-10-07 14:34:35 +0100 |
| commit | b460ea1b4f41c5547f03c316e758be61bdcd0f2e (patch) | |
| tree | 5a5e96fc1fb7beca66d297108df210367b1897c6 | |
| parent | 32543acda0fe8823bfe709015161c03037179f38 (diff) | |
| download | rabbitmq-server-git-b460ea1b4f41c5547f03c316e758be61bdcd0f2e.tar.gz | |
Deleted queue should not crash channel
This handles the case where the channel receives a message from a queue
that has recently been deleted. This crash would only occur when running
in a mixed versions cluster.
| -rw-r--r-- | src/rabbit_channel.erl | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index 089df6e24a..b3f70d87d7 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -728,13 +728,24 @@ handle_cast({mandatory_received, _MsgSeqNo}, State) -> handle_cast({reject_publish, _MsgSeqNo, QPid} = Evt, State) -> %% For backwards compatibility QRef = find_queue_name_from_pid(QPid, State#ch.queue_states), - handle_cast({queue_event, QRef, Evt}, State); + case QRef of + undefined -> + %% ignore if no queue could be found for the given pid + noreply(State); + _ -> + handle_cast({queue_event, QRef, Evt}, State) + end; handle_cast({confirm, _MsgSeqNo, QPid} = Evt, State) -> %% For backwards compatibility QRef = find_queue_name_from_pid(QPid, State#ch.queue_states), - handle_cast({queue_event, QRef, Evt}, State); - + case QRef of + undefined -> + %% ignore if no queue could be found for the given pid + noreply(State); + _ -> + handle_cast({queue_event, QRef, Evt}, State) + end; handle_cast({queue_event, QRef, Evt}, #ch{queue_states = QueueStates0} = State0) -> case rabbit_queue_type:handle_event(QRef, Evt, QueueStates0) of @@ -2716,13 +2727,17 @@ handle_queue_actions(Actions, #ch{} = State0) -> find_queue_name_from_pid(Pid, QStates) when is_pid(Pid) -> Fun = fun(K, _V, undefined) -> - {ok, Q} = rabbit_amqqueue:lookup(K), - Pids = get_queue_pids(Q), - case lists:member(Pid, Pids) of - true -> - K; - false -> - undefined + case rabbit_amqqueue:lookup(K) of + {error, not_found} -> + undefined; + {ok, Q} -> + Pids = get_queue_pids(Q), + case lists:member(Pid, Pids) of + true -> + K; + false -> + undefined + end end; (_K, _V, Acc) -> Acc |
