Closed tomyouyou closed 4 years ago
This looks OK with your example but breaks quite a few tests in RabbitMQ server. Consider providing an explanation as to how the issue manifests in RabbitMQ (e.g. come up with an integration test), not an Erlang shell code snippet.
Here's one test that triggers the issue:
# in rabbitmq-server or deps/rabbit under the umbrella
gmake ct-simple_ha
which leads to failures and the following exception in test node logs (see CT test directories with timestamps under logs
):
2019-12-23 15:16:02.569 [debug] <0.1585.0> Supervisor {<0.1585.0>,rabbit_amqqueue_sup} started rabbit_prequeue:start_link({amqqueue,{resource,<<"/">>,queue,<<"test">>},false,false,none,[],<43803.1128.0>,[<43807.1431.0>],...}, slave, <0.1584.0>) at pid <0.1586.0>
2019-12-23 15:16:02.574 [error] <0.1579.0> ** Generic server <0.1579.0> terminating
** Last message in was {'$gen_cast',{method,{'basic.consume',0,<<"test">>,<<>>,false,false,false,false,[{<<"x-cancel-on-ha-failover">>,bool,false}]},none,noflow}}
** When Server state == {ch,{conf,running,rabbit_framing_amqp_0_9_1,1,<0.1571.0>,<0.1577.0>,<0.1571.0>,<<"127.0.0.1:50607 -> 127.0.0.1:23640">>,undefined,{user,<<"guest">>,[administrator],[{rabbit_auth_backend_internal,none}]},<<"/">>,<<>>,<0.1572.0>,[{<<"publisher_confirms">>,bool,true},{<<"exchange_exchange_bindings">>,bool,true},{<<"basic.nack">>,bool,true},{<<"consumer_cancel_notify">>,bool,true},{<<"connection.blocked">>,bool,true},{<<"authentication_failure_close">>,bool,true}],none,0,134217728,undefined,#{}},{lstate,<0.1578.0>,false},none,1,{0,{[],[]}},#{},{state,#{},erlang},#{},#{},{set,0,16,16,8,80,48,{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},{{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}},{state,none,5000,undefined},false,1,{unconfirmed,{0,nil},#{},#{}},[],[],none,flow,[],#{},#Ref<0.986301929.150732801.123056>,1000000000}
** Reason for termination ==
** {function_clause,[{delegate,'-invoke/3-fun-3-',[[{ok,<43803.1128.0>,ok}],{[],[]}],[{file,"src/delegate.erl"},{line,131}]},{lists,foldl,3,[{file,"lists.erl"},{line,1263}]},{delegate,invoke,3,[{file,"src/delegate.erl"},{line,99}]},{rabbit_amqqueue,basic_consume,12,[{file,"src/rabbit_amqqueue.erl"},{line,1669}]},{rabbit_channel,'-basic_consume/8-fun-0-',10,[{file,"src/rabbit_channel.erl"},{line,1777}]},{rabbit_misc,with_exit_handler,2,[{file,"src/rabbit_misc.erl"},{line,539}]},{rabbit_channel,basic_consume,8,[{file,"src/rabbit_channel.erl"},{line,1774}]},{rabbit_channel,handle_method,3,[{file,"src/rabbit_channel.erl"},{line,1477}]}]}
2019-12-23 15:16:02.574 [error] <0.1571.0> Error on AMQP connection <0.1571.0> (127.0.0.1:50607 -> 127.0.0.1:23640, vhost: '/', user: 'guest', state: running), channel 1:
{function_clause,[{delegate,'-invoke/3-fun-3-',
[[{ok,<43803.1128.0>,ok}],{[],[]}],
[{file,"src/delegate.erl"},{line,131}]},
{lists,foldl,3,[{file,"lists.erl"},{line,1263}]},
{delegate,invoke,3,[{file,"src/delegate.erl"},{line,99}]},
{rabbit_amqqueue,basic_consume,12,
[{file,"src/rabbit_amqqueue.erl"},
{line,1669}]},
{rabbit_channel,'-basic_consume/8-fun-0-',10,
[{file,"src/rabbit_channel.erl"},
{line,1777}]},
{rabbit_misc,with_exit_handler,2,
[{file,"src/rabbit_misc.erl"},{line,539}]},
{rabbit_channel,basic_consume,8,
[{file,"src/rabbit_channel.erl"},
{line,1774}]},
{rabbit_channel,handle_method,3,
[{file,"src/rabbit_channel.erl"},
{line,1477}]}]}
In 'delegate:invoke', safe_invoke(LocalPids, FunOrMFA) returns a list, and [Results || {_Node, Results} <- Replies] is also a list, The 'lists:append/1' returns a list in which all the sublists of ListOfLists have been appended.
Please use the following code to verify: test() -> X = [1,2], Y = [3,4], lists:append([X,Y]). %% return [1,2,3,4]. %% lists:append([X | Y]) will raise a exception: %% ** exception error: bad argument %% in operator ++/2 %% called as 3 ++ 4 %% in call from lists:append/1 (lists.erl, line 127) %% in call from lists:append/1 (lists.erl, line 127)