@@ -856,7 +856,7 @@ describe.each([
856856 await assertJobTransition ( id , 'in-progress' , 'in-queue' ) ;
857857 } ) ;
858858
859- it ( 'cancel stale jobs that time out ' , async ( ) => {
859+ it ( 'cleans up stale in-progress jobs before deleting their epoch database ' , async ( ) => {
860860 const id = makeRandomProvingJobId ( ) ;
861861 await broker . enqueueProvingJob ( {
862862 id,
@@ -887,10 +887,9 @@ describe.each([
887887 inputsUri : makeInputsUri ( ) ,
888888 } ) ;
889889
890- // advance time again so job times out. Since the job was in-progress, it won't be cleaned up as stale
891- // but will be rejected when it times out
892- await sleep ( jobTimeoutMs + brokerIntervalMs ) ;
893- await assertJobStatus ( id , 'rejected' ) ;
890+ // the epoch-1 database is old enough to delete, so the broker closes any remaining epoch-1 jobs
891+ await ( broker as any ) . cleanupPass ( ) ;
892+ await assertJobStatus ( id , 'not-found' ) ;
894893 } ) ;
895894
896895 it ( 'rejects jobs that time out more than maxRetries times' , async ( ) => {
@@ -1070,13 +1069,15 @@ describe.each([
10701069 inputsUri : makeInputsUri ( ) ,
10711070 } ) ;
10721071
1073- await sleep ( brokerIntervalMs ) ;
1072+ await ( broker as any ) . cleanupPass ( ) ;
1073+ await assertJobStatus ( id , 'not-found' ) ;
10741074
1075- // job was in-progress so it won't be cleaned up as stale, but will be rejected on error
1075+ // the epoch-1 database has been deleted, so late worker reports are ignored
1076+ jest . spyOn ( database , 'setProvingJobError' ) ;
10761077 await broker . reportProvingJobError ( id , 'test error' , true ) ;
1078+ expect ( database . setProvingJobError ) . not . toHaveBeenCalled ( ) ;
10771079 await expect ( broker . getProvingJobStatus ( id ) ) . resolves . toEqual ( {
1078- status : 'rejected' ,
1079- reason : 'test error' ,
1080+ status : 'not-found' ,
10801081 } ) ;
10811082 } ) ;
10821083 } ) ;
0 commit comments