@@ -44,7 +44,8 @@ groups() ->
4444 resume ,
4545 simple_order ,
4646 straight_through ,
47- invoke
47+ invoke ,
48+ gen_server2_stats
4849 ]},
4950 {cluster_size_3 , [], [
5051 mirror_queue_auto_ack ,
@@ -213,6 +214,29 @@ invoke(Config) ->
213214 rabbit_ct_client_helpers :close_connection (Conn ),
214215 passed .
215216
217+
218+ gen_server2_stats (Config ) ->
219+ % % Synthetic test to check the invoke callback, as the bug tested here
220+ % % is only triggered with a race condition.
221+ % % When mirroring is stopped, the backing queue of rabbit_amqqueue_process
222+ % % changes from rabbit_mirror_queue_master to rabbit_priority_queue,
223+ % % which shouldn't receive any invoke call. However, there might
224+ % % be pending messages so the priority queue receives the
225+ % % `run_backing_queue` cast message sent to the old master.
226+ A = rabbit_ct_broker_helpers :get_node_config (Config , 0 , nodename ),
227+ {Conn , Ch } = rabbit_ct_client_helpers :open_connection_and_channel (Config , A ),
228+ Q = <<" gen_server2_stats_queue" >>,
229+ declare (Ch , Q , 3 ),
230+ Pid = queue_pid (Config , A , rabbit_misc :r (<<" /" >>, queue , Q )),
231+ Metrics = rabbit_ct_broker_helpers :rpc (
232+ Config , A , rabbit_core_metrics , get_gen_server2_stats ,
233+ [Pid ]),
234+ true = is_number (Metrics ),
235+ delete (Ch , Q ),
236+ rabbit_ct_client_helpers :close_channel (Ch ),
237+ rabbit_ct_client_helpers :close_connection (Conn ),
238+ passed .
239+
216240dropwhile_fetchwhile (Config ) ->
217241 {Conn , Ch } = rabbit_ct_client_helpers :open_connection_and_channel (Config , 0 ),
218242 Q = <<" dropwhile_fetchwhile-queue" >>,
0 commit comments