This is an automated email from the ASF dual-hosted git repository.

yuqi1129 pushed a commit to branch branch-1.3
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/branch-1.3 by this push:
     new 86df9e4d7f [Cherry-pick to branch-1.3] [#13420] fix(core): Fix flaky 
TestJobManagerMultiNode.testCancelJobFromAnotherNode (#13460) (#13879)
86df9e4d7f is described below

commit 86df9e4d7f7bb522352c0cbb443db20cbb8b31c9
Author: Qi Yu <[email protected]>
AuthorDate: Thu Oct 15 21:25:02 2026 +0800

    [Cherry-pick to branch-1.3] [#13420] fix(core): Fix flaky 
TestJobManagerMultiNode.testCancelJobFromAnotherNode (#13460) (#13879)
    
    ### What changes were proposed in this pull request?
    
    Cherry-pick #13460 to branch-1.3. After node A's first status pull,
    accept either `CANCELLING` or `CANCELLED` as the stored status. The
    final assertions after the second pull (`CANCELLED` and `finishedAt >
    0`) are unchanged.
    
    ### Why are the changes needed?
    
    `cancelOwnedJob` cancels the job and immediately reads its status back.
    If the local process exits before the read, the first pull already
    stores `CANCELLED`, so the test fails depending on timing. The flake
    still occurs on branch-1.3.
    
    Fix: #13420
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    `./gradlew :core:test --tests TestJobManagerMultiNode -PskipITs` (9
    passed).
    
    Co-authored-by: Jerry Shao <[email protected]>
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 .../test/java/org/apache/gravitino/job/TestJobManagerMultiNode.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git 
a/core/src/test/java/org/apache/gravitino/job/TestJobManagerMultiNode.java 
b/core/src/test/java/org/apache/gravitino/job/TestJobManagerMultiNode.java
index abed136a55..5d334c4d0a 100644
--- a/core/src/test/java/org/apache/gravitino/job/TestJobManagerMultiNode.java
+++ b/core/src/test/java/org/apache/gravitino/job/TestJobManagerMultiNode.java
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.nio.file.Files;
 import java.time.Instant;
 import java.util.Collections;
+import java.util.EnumSet;
 import java.util.concurrent.TimeUnit;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.reflect.FieldUtils;
@@ -172,7 +173,10 @@ public class TestJobManagerMultiNode extends 
TestJDBCBackend {
     Awaitility.await()
         .atMost(1, TimeUnit.MINUTES)
         .until(() -> executorA.getJobStatus(job.jobExecutionId()) == 
JobHandle.Status.CANCELLED);
-    Assertions.assertEquals(JobHandle.Status.CANCELLING, 
getJob(job.name()).status());
+    // The first pull may already see the job as CANCELLED if the process 
exits quickly.
+    Assertions.assertTrue(
+        EnumSet.of(JobHandle.Status.CANCELLING, JobHandle.Status.CANCELLED)
+            .contains(getJob(job.name()).status()));
 
     nodeA.pullAndUpdateJobStatus();
     JobEntity cancelled = getJob(job.name());

Reply via email to