@@ -105,7 +105,8 @@ groups() ->
105105 force_checkpoint ,
106106 policy_repair ,
107107 gh_12635 ,
108- replica_states
108+ replica_states ,
109+ consumer_message_is_delevered_after_snapshot
109110 ]
110111 ++ all_tests ()},
111112 {cluster_size_5 , [], [start_queue ,
@@ -1461,19 +1462,19 @@ force_checkpoint_on_queue(Config) ->
14611462 rabbit_ct_helpers :await_condition (
14621463 fun () ->
14631464 {ok , State , _ } = rpc :call (Server0 , ra , member_overview , [{RaName , Server0 }]),
1464- #{log := #{latest_checkpoint_index := LCI }} = State ,
1465+ #{log := #{snapshot_index := LCI }} = State ,
14651466 LCI =:= undefined
14661467 end ),
14671468 rabbit_ct_helpers :await_condition (
14681469 fun () ->
14691470 {ok , State , _ } = rpc :call (Server1 , ra , member_overview , [{RaName , Server1 }]),
1470- #{log := #{latest_checkpoint_index := LCI }} = State ,
1471+ #{log := #{snapshot_index := LCI }} = State ,
14711472 LCI =:= undefined
14721473 end ),
14731474 rabbit_ct_helpers :await_condition (
14741475 fun () ->
14751476 {ok , State , _ } = rpc :call (Server2 , ra , member_overview , [{RaName , Server2 }]),
1476- #{log := #{latest_checkpoint_index := LCI }} = State ,
1477+ #{log := #{snapshot_index := LCI }} = State ,
14771478 LCI =:= undefined
14781479 end ),
14791480
@@ -1490,21 +1491,21 @@ force_checkpoint_on_queue(Config) ->
14901491 fun () ->
14911492 {ok , State , _ } = rpc :call (Server0 , ra , member_overview , [{RaName , Server0 }]),
14921493 ct :pal (" Ra server state post forced checkpoint: ~tp~n " , [State ]),
1493- #{log := #{latest_checkpoint_index := LCI }} = State ,
1494+ #{log := #{snapshot_index := LCI }} = State ,
14941495 (LCI =/= undefined ) andalso (LCI >= N )
14951496 end ),
14961497 rabbit_ct_helpers :await_condition (
14971498 fun () ->
14981499 {ok , State , _ } = rpc :call (Server1 , ra , member_overview , [{RaName , Server1 }]),
14991500 ct :pal (" Ra server state post forced checkpoint: ~tp~n " , [State ]),
1500- #{log := #{latest_checkpoint_index := LCI }} = State ,
1501+ #{log := #{snapshot_index := LCI }} = State ,
15011502 (LCI =/= undefined ) andalso (LCI >= N )
15021503 end ),
15031504 rabbit_ct_helpers :await_condition (
15041505 fun () ->
15051506 {ok , State , _ } = rpc :call (Server2 , ra , member_overview , [{RaName , Server2 }]),
15061507 ct :pal (" Ra server state post forced checkpoint: ~tp~n " , [State ]),
1507- #{log := #{latest_checkpoint_index := LCI }} = State ,
1508+ #{log := #{snapshot_index := LCI }} = State ,
15081509 (LCI =/= undefined ) andalso (LCI >= N )
15091510 end ).
15101511
@@ -1780,6 +1781,60 @@ dont_leak_file_handles(Config) ->
17801781 rabbit_ct_client_helpers :close_channel (C ),
17811782 ok .
17821783
1784+ consumer_message_is_delevered_after_snapshot (Config ) ->
1785+ % % a consumer on a node that received a snapshot should have it's messages
1786+ % % delivered
1787+ [Server0 , _Server1 , Server2 ] =
1788+ rabbit_ct_broker_helpers :get_node_configs (Config , nodename ),
1789+
1790+ ok = rabbit_ct_broker_helpers :rpc (Config , 0 , application , set_env ,
1791+ [rabbit , quorum_min_checkpoint_interval , 1 ]),
1792+
1793+ Ch0 = rabbit_ct_client_helpers :open_channel (Config , Server0 ),
1794+ # 'confirm.select_ok' {} = amqp_channel :call (Ch0 , # 'confirm.select' {}),
1795+ QQ = ? config (queue_name , Config ),
1796+ RaName = ra_name (QQ ),
1797+ ? assertEqual ({'queue.declare_ok' , QQ , 0 , 0 },
1798+ declare (Ch0 , QQ , [{<<" x-queue-type" >>, longstr , <<" quorum" >>}])),
1799+
1800+ % % stop server on a follower node
1801+ ok = rpc :call (Server2 , ra , stop_server , [quorum_queues , {RaName , Server2 }]),
1802+ Ch2 = rabbit_ct_client_helpers :open_channel (Config , Server2 ),
1803+ % % create a consumer
1804+ qos (Ch2 , 2 , false ),
1805+ subscribe (Ch2 , QQ , false ),
1806+
1807+ % % publish some messages and make sure a snapshot has been taken
1808+ Msg = crypto :strong_rand_bytes (13_000 ),
1809+
1810+ [publish (Ch0 , QQ , Msg ) || _ <- lists :seq (1 , 5000 )],
1811+ amqp_channel :wait_for_confirms (Ch0 , 5 ),
1812+ % % need to sleep here a bit as QQs wont take
1813+ % % snapshots more often than once every second
1814+ timer :sleep (1100 ),
1815+
1816+ % % then purge
1817+ # 'queue.purge_ok' {} = amqp_channel :call (Ch0 , # 'queue.purge' {queue = QQ }),
1818+
1819+ rabbit_ct_helpers :await_condition_ignoring_exceptions (
1820+ fun () ->
1821+ {ok , #{log := Log }, _ } = rpc :call (Server0 , ra , member_overview ,
1822+ [{RaName , Server0 }]),
1823+ undefined =/= maps :get (snapshot_index , Log )
1824+ end ),
1825+ % % restart stopped member
1826+ ok = rpc :call (Server2 , ra , restart_server , [quorum_queues , {RaName , Server2 }]),
1827+
1828+ % % messages should be delivered
1829+ receive
1830+ {# 'basic.deliver' {delivery_tag = _DeliveryTag }, _ } ->
1831+ ok
1832+ after 30000 ->
1833+ flush (1 ),
1834+ ct :fail (" expected messages were not delivered" )
1835+ end ,
1836+ ok .
1837+
17831838gh_12635 (Config ) ->
17841839 check_quorum_queues_v4_compat (Config ),
17851840
@@ -1788,7 +1843,7 @@ gh_12635(Config) ->
17881843 rabbit_ct_broker_helpers :get_node_configs (Config , nodename ),
17891844
17901845 ok = rabbit_ct_broker_helpers :rpc (Config , 0 , application , set_env ,
1791- [rabbit , quorum_min_checkpoint_interval , 1 ]),
1846+ [rabbit , quorum_snapshot_interval , 1 ]),
17921847
17931848 Ch0 = rabbit_ct_client_helpers :open_channel (Config , Server0 ),
17941849 # 'confirm.select_ok' {} = amqp_channel :call (Ch0 , # 'confirm.select' {}),
@@ -1810,7 +1865,7 @@ gh_12635(Config) ->
18101865 rabbit_ct_helpers :await_condition (
18111866 fun () ->
18121867 {ok , #{log := Log }, _ } = rpc :call (Server0 , ra , member_overview , [{RaName , Server0 }]),
1813- undefined =/= maps :get (latest_checkpoint_index , Log )
1868+ undefined =/= maps :get (snapshot_index , Log )
18141869 end ),
18151870
18161871 % % publish 1 more message
0 commit comments