Skip to content

Commit

Permalink
WIP reader process was under different supervisor
Browse files Browse the repository at this point in the history
Maybe to fix this issue we can look up the process
in ETC done by rabbit_connection_tracker module.
At the moment, this is one reader process but
when we query its info, the process crashes
calling exactly the function which resolves user item info.

crasher:
 initial call: rabbit_reader:init/3
 pid: <0.769.0>
 exception error: no function clause matching
              rabbit_amqp1_0_reader:info_internal(user,
  • Loading branch information
MarcialRosales authored and lukebakken committed Sep 27, 2022
1 parent e3f486e commit f48e013
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
6 changes: 4 additions & 2 deletions deps/rabbitmq_amqp1_0/src/rabbit_amqp1_0.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ connection_info_local(Items) ->
list() ->
[ReaderPid
|| {_, TcpPid, _, [tcp_listener_sup]} <- supervisor:which_children(rabbit_sup),
{_, RanchLPid, _, [ranch_listener_sup]} <- supervisor:which_children(TcpPid),
{_, RanchCPid, _, [ranch_conns_sup]} <- supervisor:which_children(RanchLPid),
{_, RanchEPid, _, [ranch_embedded_sup]} <- supervisor:which_children(TcpPid),
{_, RanchLPid, _, [ranch_listener_sup]} <- supervisor:which_children(RanchEPid),
{_, RanchCSPid, _, [ranch_conns_sup_sup]} <- supervisor:which_children(RanchLPid),
{_, RanchCPid, _, [ranch_conns_sup]} <- supervisor:which_children(RanchCSPid),
{rabbit_connection_sup, ConnPid, _, _} <- supervisor:which_children(RanchCPid),
{reader, ReaderPid, _, _} <- supervisor:which_children(ConnPid)
].
1 change: 1 addition & 0 deletions deps/rabbitmq_amqp1_0/src/rabbit_amqp1_0_reader.erl
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ handle_other({bump_credit, Msg}, State) ->
handle_other(terminate_connection, State) ->
State;
handle_other({info, InfoItems, Pid}, State) ->
logger:info("Reader info: State: ~p pid ~p infoitems: ~p ", [State, Pid, InfoItems]),
Infos = lists:map(
fun(InfoItem) ->
{InfoItem, info_internal(InfoItem, State)}
Expand Down
39 changes: 39 additions & 0 deletions deps/rabbitmq_amqp1_0/test/command_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,45 @@ when_one_connection(_Config) ->
rabbit_ct_broker_helpers:rpc(_Config, A,
rabbit_connection_tracking, list, []),

[P1, P2] = [P
|| {_, P, _, [tcp_listener_sup]} <- rabbit_ct_broker_helpers:rpc(_Config, A, supervisor,which_children, [rabbit_sup])],
println("Pid1", P1),
println("Pid2", P2),

Children1 = rabbit_ct_broker_helpers:rpc(_Config, A, supervisor,which_children,[P1]),
println("tcp_listener_sup1", Children1),
Children2 = rabbit_ct_broker_helpers:rpc(_Config, A, supervisor,which_children,[P2]),
println("tcp_listener_sup2", Children2),

[Res1, Res2] = [RanchSupPid
|| {_, TcpPid, _, [tcp_listener_sup]} <- rabbit_ct_broker_helpers:rpc(_Config, A, supervisor, which_children, [rabbit_sup]),
{_, RanchSupPid, _, [ranch_embedded_sup]} <- rabbit_ct_broker_helpers:rpc(_Config, A, supervisor, which_children, [TcpPid])
],
println("ranch_embedded_sup 1", rabbit_ct_broker_helpers:rpc(_Config, A, supervisor,which_children,[Res1])),
println("ranch_embedded_sup 2", rabbit_ct_broker_helpers:rpc(_Config, A, supervisor,which_children,[Res2])),

[Rl1, Rl2] = [RanchLPid
|| {_, TcpPid, _, [tcp_listener_sup]} <- rabbit_ct_broker_helpers:rpc(_Config, A, supervisor, which_children, [rabbit_sup]),
{_, RanchEPid, _, [ranch_embedded_sup]} <- rabbit_ct_broker_helpers:rpc(_Config, A, supervisor, which_children, [TcpPid]),
{_, RanchLPid, _, [ranch_listener_sup]} <- rabbit_ct_broker_helpers:rpc(_Config, A, supervisor, which_children, [RanchEPid])
],
println("ranch_listener_sup", [Rl1, Rl2]),
println("ranch_listener_sup 1", rabbit_ct_broker_helpers:rpc(_Config, A, supervisor,which_children,[Rl1])),
println("ranch_listener_sup 2", rabbit_ct_broker_helpers:rpc(_Config, A, supervisor,which_children,[Rl2])),

ReaderPids = [ReaderPid
|| {_, TcpPid, _, [tcp_listener_sup]} <- rabbit_ct_broker_helpers:rpc(_Config, A, supervisor, which_children, [rabbit_sup]),
{_, RanchEPid, _, [ranch_embedded_sup]} <- rabbit_ct_broker_helpers:rpc(_Config, A, supervisor, which_children, [TcpPid]),
{_, RanchLPid, _, [ranch_listener_sup]} <- rabbit_ct_broker_helpers:rpc(_Config, A, supervisor, which_children, [RanchEPid]),
{_, RanchSPid, _, [ranch_conns_sup_sup]} <- rabbit_ct_broker_helpers:rpc(_Config, A, supervisor, which_children, [RanchLPid]),
{_, RanchCPid, _, [ranch_conns_sup]} <- rabbit_ct_broker_helpers:rpc(_Config, A, supervisor, which_children, [RanchSPid]),
{rabbit_connection_sup, ConnPid, _, _} <- supervisor:which_children(RanchCPid),
{reader, ReaderPid, _, _} <- supervisor:which_children(ConnPid)
],
println("ReaderPid", ReaderPids),
ReaderInfos = [rabbit_ct_broker_helpers:rpc(_Config, A, rabbit_amqp1_0_reader, info, [Pid, [node,user]]) || Pid <- ReaderPids],
println("ReaderPid info",ReaderInfos),

[ExpectedConnection] = 'Elixir.Enum':to_list(?COMMAND:run([], Opts)),
close_amqp10_connection(Connection).

Expand Down

0 comments on commit f48e013

Please sign in to comment.