Skip to content

Commit f36e9f0

Browse files
author
yinqi.yl
committed
[FLINK-38272][runtime] Fix unstable BatchJobRecoveryTest
1 parent 39a4628 commit f36e9f0

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptivebatch/BatchJobRecoveryTest.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,11 @@ void testRecoverFromJMFailover() throws Exception {
264264
}
265265

266266
waitUntilWriteExecutionVertexFinishedEventPersisted(5);
267-
runInMainThread(() -> jobEventStore.stop(false));
267+
runInMainThread(
268+
() -> {
269+
scheduler.cancel();
270+
jobEventStore.stop(false);
271+
});
268272

269273
// register all produced partitions
270274
registerPartitions(scheduler);
@@ -360,7 +364,11 @@ void testJobVertexUnFinishedAndOperatorCoordinatorNotSupportBatchSnapshot() thro
360364
getCurrentAttemptIds(scheduler.getExecutionJobVertex(MIDDLE_ID));
361365

362366
waitUntilWriteExecutionVertexFinishedEventPersisted(6);
363-
runInMainThread(() -> jobEventStore.stop(false));
367+
runInMainThread(
368+
() -> {
369+
scheduler.cancel();
370+
jobEventStore.stop(false);
371+
});
364372

365373
// register partitions, the partition of source task 0 is lost, and it will be restarted
366374
// if middle task 0 need be restarted.
@@ -462,6 +470,7 @@ void testJobVertexFinishedAndOperatorCoordinatorNotSupportBatchSnapshotAndPartit
462470
waitUntilWriteExecutionVertexFinishedEventPersisted(5);
463471
runInMainThread(
464472
() -> {
473+
scheduler.cancel();
465474
jobEventStore.stop(false);
466475
});
467476

@@ -548,7 +557,11 @@ void testRecoverFromJMFailoverAndPartitionsUnavailable() throws Exception {
548557
getCurrentAttemptIds(scheduler.getExecutionJobVertex(SOURCE_ID));
549558

550559
waitUntilWriteExecutionVertexFinishedEventPersisted(5);
551-
runInMainThread(() -> jobEventStore.stop(false));
560+
runInMainThread(
561+
() -> {
562+
scheduler.cancel();
563+
jobEventStore.stop(false);
564+
});
552565

553566
int losePartitionsTaskIndex = 0;
554567

@@ -619,7 +632,11 @@ void testRecoverDecidedParallelismFromTheSameJobGraphInstance() throws Exception
619632
getCurrentAttemptIds(scheduler.getExecutionJobVertex(SINK_ID));
620633

621634
waitUntilWriteExecutionVertexFinishedEventPersisted(12);
622-
runInMainThread(() -> jobEventStore.stop(false));
635+
runInMainThread(
636+
() -> {
637+
scheduler.cancel();
638+
jobEventStore.stop(false);
639+
});
623640

624641
// start a new scheduler and try to recover.
625642
AdaptiveBatchScheduler newScheduler = createScheduler(jobGraph);
@@ -682,6 +699,7 @@ void testPartitionNotFoundTwiceAfterJMFailover() throws Exception {
682699
waitUntilWriteExecutionVertexFinishedEventPersisted(5);
683700
runInMainThread(
684701
() -> {
702+
scheduler.cancel();
685703
jobEventStore.stop(false);
686704
});
687705

0 commit comments

Comments
 (0)