You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "Jackie-Jiang (via GitHub)" <gi...@apache.org> on 2026/08/15 19:37:08 UTC

[PR] Fix flaky waitForMinionTaskCompletion by waiting for subtask states to become terminal [pinot]

Jackie-Jiang opened a new pull request, #19265:
URL: https://github.com/apache/pinot/pull/19265

   ## Summary
   
   `waitForMinionTaskCompletion` waited only for the task-level state to reach `COMPLETED`, then immediately asserted that every subtask state is `COMPLETED`. The two reads come from different Helix znodes (the task state from the WorkflowContext, the subtask map from the JobContext) that are not updated atomically, so the assertion can read a stale subtask state right after the task turns `COMPLETED` and fail spuriously:
   
   ```
   Not all subtasks are completed for task Task_SegmentPurgeTask_..._1786749842426 :
     {..._0=COMPLETED, ..._1=RUNNING} expected [true] but found [false]
   ```
   
   Since Helix only marks a job `COMPLETED` after every partition reaches a terminal state, a `RUNNING` (or `null`, not yet started — `getSubtaskStates` can genuinely return null values) subtask under a `COMPLETED` task is a stale read, not a still-running subtask.
   
   The wait condition now also requires a non-empty subtask map with every subtask in a terminal state, converting the stale read into a slightly longer wait. The final assertion (all subtasks `COMPLETED`) is unchanged, so a job that completes with genuinely failed subtasks (failure-threshold semantics — the case the assertion exists to catch) still fails immediately with the informative state map instead of burning the timeout.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Fix flaky waitForMinionTaskCompletion by waiting for subtask states to become terminal [pinot]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #19265:
URL: https://github.com/apache/pinot/pull/19265#discussion_r3790116599


##########
pinot-integration-test-base/src/test/java/org/apache/pinot/integration/tests/BaseClusterIntegrationTest.java:
##########
@@ -979,19 +990,26 @@ protected long getCurrentCountStarResult(String tableName) {
   }
 
   protected void waitForMinionTaskCompletion(String taskId, long timeout) {
-    TestUtils.waitForCondition(aVoid ->
-            _controllerStarter.getHelixTaskResourceManager().getTaskState(taskId) == TaskState.COMPLETED,
-        timeout, "Failed to complete the task " + taskId);
-
-    // Validate that there were > 0 subtasks so that we know the task was actually run
-    Assert.assertFalse(_controllerStarter.getHelixTaskResourceManager().getSubtaskStates(taskId).isEmpty());
+    // The task state (workflow context) and the subtask states (job context) live in different Helix znodes and are
+    // not updated atomically, so a subtask can still read as RUNNING (or null, not yet started) right after the task
+    // turns COMPLETED. Wait until the task is COMPLETED and every subtask reached a terminal state before validating
+    // them. A non-empty subtask map also proves the task was actually run.
+    PinotHelixTaskResourceManager taskResourceManager = _controllerStarter.getHelixTaskResourceManager();
+    TestUtils.waitForCondition(aVoid -> {
+      if (taskResourceManager.getTaskState(taskId) != TaskState.COMPLETED) {
+        return false;
+      }
+      Map<String, TaskPartitionState> subtaskStates = taskResourceManager.getSubtaskStates(taskId);
+      return !subtaskStates.isEmpty() && subtaskStates.values()
+          .stream()
+          .noneMatch(state -> state == null || state == TaskPartitionState.INIT || state == TaskPartitionState.RUNNING);

Review Comment:
   `STOPPED` is also non-terminal for Helix task partitions because a stopped partition can be resumed. Treating every state other than `null`, `INIT`, and `RUNNING` as terminal lets a stale `STOPPED` value satisfy this wait, after which the unchanged assertion can fail immediately—the same race this change is intended to remove. Include `STOPPED` in the states that keep polling.



##########
pinot-integration-test-base/src/test/java/org/apache/pinot/integration/tests/BaseClusterIntegrationTest.java:
##########
@@ -329,22 +333,20 @@ protected Schema createSchema(File schemaFile)
   protected TableConfig createTableConfig(String tableConfigFileName)
       throws IOException {
     URL configPathUrl = getClass().getClassLoader().getResource(tableConfigFileName);
-    Assert.assertNotNull(configPathUrl);
+    assertNotNull(configPathUrl);
     return createTableConfig(new File(configPathUrl.getFile()));
   }
 
   protected TableConfig createTableConfig(File tableConfigFile)
       throws IOException {
     InputStream inputStream = new FileInputStream(tableConfigFile);
-    Assert.assertNotNull(inputStream);
+    assertNotNull(inputStream);
     return JsonUtils.inputStreamToObject(inputStream, TableConfig.class);
   }
 
   /// Creates a new OFFLINE table config.
   protected TableConfig createOfflineTableConfig() {
-    // @formatter:off
-    return new TableConfigBuilder(TableType.OFFLINE)
-        .setTableName(getTableName())
+    return new TableConfigBuilder(TableType.OFFLINE).setTableName(getTableName())

Review Comment:
   This begins a series of formatting-only changes across unrelated builders, Kafka helpers, connection setup, and assertions, while the PR's behavior change is confined to the minion wait helper. The repository requires minimal diffs and preserving unrelated formatting; please revert these non-functional hunks so the race fix remains reviewable and avoids unnecessary merge conflicts.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Fix flaky waitForMinionTaskCompletion by waiting for subtask states to become terminal [pinot]

Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang commented on code in PR #19265:
URL: https://github.com/apache/pinot/pull/19265#discussion_r3790492879


##########
pinot-integration-test-base/src/test/java/org/apache/pinot/integration/tests/BaseClusterIntegrationTest.java:
##########
@@ -979,19 +990,26 @@ protected long getCurrentCountStarResult(String tableName) {
   }
 
   protected void waitForMinionTaskCompletion(String taskId, long timeout) {
-    TestUtils.waitForCondition(aVoid ->
-            _controllerStarter.getHelixTaskResourceManager().getTaskState(taskId) == TaskState.COMPLETED,
-        timeout, "Failed to complete the task " + taskId);
-
-    // Validate that there were > 0 subtasks so that we know the task was actually run
-    Assert.assertFalse(_controllerStarter.getHelixTaskResourceManager().getSubtaskStates(taskId).isEmpty());
+    // The task state (workflow context) and the subtask states (job context) live in different Helix znodes and are
+    // not updated atomically, so a subtask can still read as RUNNING (or null, not yet started) right after the task
+    // turns COMPLETED. Wait until the task is COMPLETED and every subtask reached a terminal state before validating
+    // them. A non-empty subtask map also proves the task was actually run.
+    PinotHelixTaskResourceManager taskResourceManager = _controllerStarter.getHelixTaskResourceManager();
+    TestUtils.waitForCondition(aVoid -> {
+      if (taskResourceManager.getTaskState(taskId) != TaskState.COMPLETED) {
+        return false;
+      }
+      Map<String, TaskPartitionState> subtaskStates = taskResourceManager.getSubtaskStates(taskId);
+      return !subtaskStates.isEmpty() && subtaskStates.values()
+          .stream()
+          .noneMatch(state -> state == null || state == TaskPartitionState.INIT || state == TaskPartitionState.RUNNING);

Review Comment:
   Fixed in b45ae88: `STOPPED` is now treated as non-terminal in the wait condition. You are right on the lifecycle — a `STOPPED` partition is resumable, so under a `COMPLETED` task it can only be a stale read of a stop-then-resume history, and exiting the wait on it re-opens the same race. Note this cannot cause spurious timeouts in legitimate scenarios: a genuinely stopped task has job state `STOPPED`, never `COMPLETED`, so the wait would already be blocked on the task-state check.



##########
pinot-integration-test-base/src/test/java/org/apache/pinot/integration/tests/BaseClusterIntegrationTest.java:
##########
@@ -329,22 +333,20 @@ protected Schema createSchema(File schemaFile)
   protected TableConfig createTableConfig(String tableConfigFileName)
       throws IOException {
     URL configPathUrl = getClass().getClassLoader().getResource(tableConfigFileName);
-    Assert.assertNotNull(configPathUrl);
+    assertNotNull(configPathUrl);
     return createTableConfig(new File(configPathUrl.getFile()));
   }
 
   protected TableConfig createTableConfig(File tableConfigFile)
       throws IOException {
     InputStream inputStream = new FileInputStream(tableConfigFile);
-    Assert.assertNotNull(inputStream);
+    assertNotNull(inputStream);
     return JsonUtils.inputStreamToObject(inputStream, TableConfig.class);
   }
 
   /// Creates a new OFFLINE table config.
   protected TableConfig createOfflineTableConfig() {
-    // @formatter:off
-    return new TableConfigBuilder(TableType.OFFLINE)
-        .setTableName(getTableName())
+    return new TableConfigBuilder(TableType.OFFLINE).setTableName(getTableName())

Review Comment:
   The formatting cleanup is intentional: this is a test-infrastructure file, and the reformat drops stale `@formatter:off` guards and normalizes builder chains to the current repo style. Doing it in a commit that already touches the file avoids a dedicated churn PR; the behavior change remains confined to `waitForMinionTaskCompletion` and is easy to review in isolation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Fix flaky waitForMinionTaskCompletion by waiting for subtask states to become terminal [pinot]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #19265:
URL: https://github.com/apache/pinot/pull/19265#issuecomment-5304100064

   ## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/19265?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 39.02%. Comparing base ([`c27e3a7`](https://app.codecov.io/gh/apache/pinot/commit/c27e3a777019b885e61ded96fc52d33c43574542?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`3c00bf2`](https://app.codecov.io/gh/apache/pinot/commit/3c00bf2351c690b525c7b33062299e2df25f492b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   > :exclamation:  There is a different number of reports uploaded between BASE (c27e3a7) and HEAD (3c00bf2). Click for more details.
   > 
   > <details><summary>HEAD has 24 uploads less than BASE</summary>
   >
   >| Flag | BASE (c27e3a7) | HEAD (3c00bf2) |
   >|------|------|------|
   >|unittests1|1|0|
   >|unittests|2|1|
   >|java-25|6|1|
   >|temurin|6|1|
   >|lane-a|2|0|
   >|integration|4|0|
   >|integration1|2|0|
   >|lane-b|2|0|
   >|integration2|2|0|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@              Coverage Diff              @@
   ##             master   #19265       +/-   ##
   =============================================
   - Coverage     66.98%   39.02%   -27.96%     
   + Complexity     1423     1416        -7     
   =============================================
     Files          3453     3453               
     Lines        218960   218960               
     Branches      34805    34805               
   =============================================
   - Hits         146672    85457    -61215     
   - Misses        60566   125689    +65123     
   + Partials      11722     7814     -3908     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/pinot/pull/19265/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [integration](https://app.codecov.io/gh/apache/pinot/pull/19265/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration1](https://app.codecov.io/gh/apache/pinot/pull/19265/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration2](https://app.codecov.io/gh/apache/pinot/pull/19265/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [java-25](https://app.codecov.io/gh/apache/pinot/pull/19265/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.02% <ø> (-27.96%)` | :arrow_down: |
   | [lane-a](https://app.codecov.io/gh/apache/pinot/pull/19265/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [lane-b](https://app.codecov.io/gh/apache/pinot/pull/19265/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [temurin](https://app.codecov.io/gh/apache/pinot/pull/19265/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.02% <ø> (-27.96%)` | :arrow_down: |
   | [unittests](https://app.codecov.io/gh/apache/pinot/pull/19265/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.02% <ø> (-27.96%)` | :arrow_down: |
   | [unittests1](https://app.codecov.io/gh/apache/pinot/pull/19265/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unittests2](https://app.codecov.io/gh/apache/pinot/pull/19265/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.02% <ø> (-0.02%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/pinot/pull/19265?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Fix flaky waitForMinionTaskCompletion by waiting for subtask states to become terminal [pinot]

Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang merged PR #19265:
URL: https://github.com/apache/pinot/pull/19265


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org