@@ -58,6 +58,7 @@ all_tests() ->
5858 wal_loses_writer_state ,
5959 detect_lost_written_range ,
6060 snapshot_installation ,
61+ snapshot_installation_with_no_live_indexes_overtakes_written ,
6162 snapshot_written_after_installation ,
6263 oldcheckpoints_deleted_after_snapshot_install ,
6364 append_after_snapshot_installation_with_live_indexes ,
@@ -177,7 +178,6 @@ snapshot_before_written(Config) ->
177178 end ),
178179 ok .
179180
180-
181181handle_overwrite (Config ) ->
182182 Log0 = ra_log_init (Config ),
183183 {ok , Log1 } = ra_log :write ([{1 , 1 , " value" },
@@ -1625,6 +1625,38 @@ snapshot_installation(Config) ->
16251625 {[_ , _ ], _ } = ra_log_take (16 , 17 , Log ),
16261626 ok .
16271627
1628+ snapshot_installation_with_no_live_indexes_overtakes_written (Config ) ->
1629+ Log0 = ra_log_init (Config ),
1630+ {0 , 0 } = ra_log :last_index_term (Log0 ),
1631+ Log1 = assert_log_events (write_n (1 , 10 , 2 , Log0 ),
1632+ fun (L ) -> {9 , 2 } == ra_log :last_written (L ) end ),
1633+
1634+ true = ra_log_wal_SUITE :suspend_process (whereis (ra_log_wal )),
1635+ Log2 = write_n (1 , 10 , 2 , Log1 ),
1636+
1637+ % % create snapshot chunk
1638+ Meta = meta (15 , 2 , [? N1 ]),
1639+ Chunk = create_snapshot_chunk (Config , Meta , #{}),
1640+ SnapState0 = ra_log :snapshot_state (Log2 ),
1641+ {ok , SnapState1 } = ra_snapshot :begin_accept (Meta , SnapState0 ),
1642+ Machine = {machine , ? MODULE , #{}},
1643+ {SnapState , _ , [], AEffs } =
1644+ ra_snapshot :complete_accept (Chunk , 1 , Machine , SnapState1 ),
1645+ run_effs (AEffs ),
1646+ {ok , Log3 , Effs4 } = ra_log :install_snapshot ({15 , 2 }, ? MODULE , [],
1647+ ra_log :set_snapshot_state (SnapState , Log2 )),
1648+
1649+ run_effs (Effs4 ),
1650+ {15 , _ } = ra_log :last_index_term (Log3 ),
1651+ {15 , _ } = ra_log :last_written (Log3 ),
1652+ #{mem_table_range := undefined } = ra_log :overview (Log3 ),
1653+
1654+ true = erlang :resume_process (whereis (ra_log_wal )),
1655+ Log4 = write_n (16 , 20 , 2 , Log3 ),
1656+ _ = assert_log_events (Log4 ,
1657+ fun (L ) -> {19 , 2 } == ra_log :last_written (L ) end ),
1658+ ok .
1659+
16281660append_after_snapshot_installation_with_live_indexes (Config ) ->
16291661 logger :set_primary_config (level , all ),
16301662 % % simulates scenario where a node becomes leader after receiving a
0 commit comments