@@ -461,6 +461,7 @@ mod tests {
461461 job_id : JobId :: new ( "J" ) ,
462462 generation : Generation ( 1 ) ,
463463 updated_at : from_micros ( 123 ) ,
464+ ignore_state_before_generation : None ,
464465 } ,
465466 false ,
466467 )
@@ -516,6 +517,7 @@ mod tests {
516517 job_id : JobId :: new ( "J" ) ,
517518 generation : Generation ( 2 ) ,
518519 updated_at : from_micros ( 456 ) ,
520+ ignore_state_before_generation : None ,
519521 } ,
520522 false ,
521523 )
@@ -547,6 +549,75 @@ mod tests {
547549 assert_eq ! ( written_manifest, expected_manifest) ;
548550 }
549551
552+ #[ tokio:: test]
553+ async fn initialize_generation_keeps_ignoring_old_state_on_retry ( ) {
554+ let store = MemoryProtocolStore :: default ( ) ;
555+ let paths = ProtocolPaths :: new ( PipelineId :: new ( "P" ) , JobId :: new ( "J" ) ) ;
556+ write_current_generation ( & store, & paths, Generation ( 3 ) ) . await ;
557+
558+ let checkpoint_ref = paths. checkpoint_manifest ( Generation ( 1 ) , Epoch ( 1 ) ) ;
559+ let checkpoint = checkpoint_for_generation ( Generation ( 1 ) , 1 , None , false ) ;
560+ write_canonical_checkpoint ( & store, & paths, & checkpoint_ref, & checkpoint) . await ;
561+ let previous_manifest =
562+ generation_manifest_for_generation ( Generation ( 1 ) , None , Some ( checkpoint_ref) ) ;
563+ put_json (
564+ & store,
565+ & paths. generation_manifest ( Generation ( 1 ) ) ,
566+ & previous_manifest,
567+ )
568+ . await
569+ . unwrap ( ) ;
570+ put_json (
571+ & store,
572+ & paths. generation_manifest ( Generation ( 2 ) ) ,
573+ & GenerationManifest :: new (
574+ PipelineId :: new ( "P" ) ,
575+ JobId :: new ( "J" ) ,
576+ Generation ( 2 ) ,
577+ None ,
578+ 123 ,
579+ ) ,
580+ )
581+ . await
582+ . unwrap ( ) ;
583+
584+ let initialization = initialize_generation (
585+ & store,
586+ InitializeGenerationRequest {
587+ pipeline_id : PipelineId :: new ( "P" ) ,
588+ job_id : JobId :: new ( "J" ) ,
589+ generation : Generation ( 3 ) ,
590+ updated_at : from_micros ( 456 ) ,
591+ ignore_state_before_generation : Some ( Generation ( 2 ) ) ,
592+ } ,
593+ false ,
594+ )
595+ . await
596+ . unwrap ( ) ;
597+
598+ let expected_manifest = GenerationManifest :: new (
599+ PipelineId :: new ( "P" ) ,
600+ JobId :: new ( "J" ) ,
601+ Generation ( 3 ) ,
602+ None ,
603+ 456 ,
604+ ) ;
605+ assert_eq ! (
606+ initialization,
607+ GenerationInitialization :: Initialized {
608+ generation_manifest: expected_manifest. clone( ) ,
609+ recovery: GenerationRecovery :: NoCheckpoint ,
610+ }
611+ ) ;
612+
613+ let written_manifest: GenerationManifest =
614+ read_json ( & store, & paths. generation_manifest ( Generation ( 3 ) ) )
615+ . await
616+ . unwrap ( )
617+ . expect ( "new generation manifest should be written" ) ;
618+ assert_eq ! ( written_manifest, expected_manifest) ;
619+ }
620+
550621 #[ tokio:: test]
551622 async fn initialize_generation_restores_previous_checkpoint_requiring_commit_replay ( ) {
552623 let store = MemoryProtocolStore :: default ( ) ;
@@ -573,6 +644,7 @@ mod tests {
573644 job_id : JobId :: new ( "J" ) ,
574645 generation : Generation ( 2 ) ,
575646 updated_at : from_micros ( 456 ) ,
647+ ignore_state_before_generation : None ,
576648 } ,
577649 false ,
578650 )
@@ -621,6 +693,7 @@ mod tests {
621693 job_id : JobId :: new ( "J" ) ,
622694 generation : Generation ( 3 ) ,
623695 updated_at : from_micros ( 789 ) ,
696+ ignore_state_before_generation : None ,
624697 } ,
625698 false ,
626699 )
@@ -668,6 +741,7 @@ mod tests {
668741 job_id : JobId :: new ( "J" ) ,
669742 generation : Generation ( 2 ) ,
670743 updated_at : from_micros ( 456 ) ,
744+ ignore_state_before_generation : None ,
671745 } ,
672746 false ,
673747 )
@@ -724,6 +798,7 @@ mod tests {
724798 job_id : JobId :: new ( "J" ) ,
725799 generation : Generation ( 3 ) ,
726800 updated_at : from_micros ( 456 ) ,
801+ ignore_state_before_generation : None ,
727802 } ,
728803 false ,
729804 )
@@ -789,6 +864,7 @@ mod tests {
789864 job_id : JobId :: new ( "J" ) ,
790865 generation : Generation ( 3 ) ,
791866 updated_at : from_micros ( 456 ) ,
867+ ignore_state_before_generation : None ,
792868 } ,
793869 false ,
794870 )
@@ -826,6 +902,7 @@ mod tests {
826902 job_id : JobId :: new ( "J" ) ,
827903 generation : Generation ( 2 ) ,
828904 updated_at : from_micros ( 456 ) ,
905+ ignore_state_before_generation : None ,
829906 } ,
830907 false ,
831908 )
0 commit comments