You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/12/08 07:35:40 UTC

[GitHub] [flink] chucheng92 opened a new pull request, #21464: [FLINK-30334] Reset SourceCoordinator#handleRequestSplitEvent without…

chucheng92 opened a new pull request, #21464:
URL: https://github.com/apache/flink/pull/21464

   ## What is the purpose of the change
   
   SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the HybridSource situation. It will cause HybridSource do not read next child sources data and finally loss data and with unexpected behavior.
   
   ## Brief change log
   
   Reset SourceCoordinator#handleRequestSplitEvent to 1.15 without hasNoMoreSplits check.
   
   ## Verifying this change
   
   Not add new cases. It can be tested by current cases.
   
   ## Does this pull request potentially affect one of the following parts:
   
   - Dependencies (does it add or upgrade a dependency): no
   - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no
   - The serializers: no
   - The runtime per-record code paths (performance sensitive): no
   - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
   - The S3 file system connector: no
   
   ## Documentation
   
   - Does this pull request introduce a new feature?  no
   - If yes, how is the feature documented? not applicable


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on a diff in pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on code in PR #21464:
URL: https://github.com/apache/flink/pull/21464#discussion_r1056014959


##########
flink-core/src/main/java/org/apache/flink/api/connector/source/SplitEnumeratorContext.java:
##########
@@ -126,6 +126,16 @@ default void assignSplit(SplitT split, int subtask) {
      */
     void signalNoMoreSplits(int subtask);
 
+    /**
+     * Signals a subtask that it will not receive split for current source, but it will receive
+     * split for next sources. A common scenario is HybridSource. This indicates that task not truly
+     * read finished.
+     *
+     * @param subtask The index of the operator's parallel subtask that shall be signaled it will
+     *     receive splits later.
+     */
+    default void signalIntermediateNoMoreSplits(int subtask) {}

Review Comment:
   @zhuzhurk Yes. SplitEnumeratorContext is a Public api. i add it with default method to avoid impact. We can not use `realContext instanceOf SourceCoordinatorContext` directly, HybridSourceSplitEnumerator is in flink-connector-base, SourceCoordinatorContext is in flink-runtime, how can we reference it?  using class FQDN or add runtime dependency both are ugly.  Is there a more elegant way ?



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on a diff in pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on code in PR #21464:
URL: https://github.com/apache/flink/pull/21464#discussion_r1057102434


##########
flink-runtime/src/main/java/org/apache/flink/runtime/source/coordinator/SourceCoordinatorContext.java:
##########
@@ -289,6 +290,20 @@ public void signalNoMoreSplits(int subtask) {
                 "Failed to send 'NoMoreSplits' to reader " + subtask);
     }
 
+    @Override
+    public void signalIntermediateNoMoreSplits(int subtask) {
+        checkSubtaskIndex(subtask);
+
+        // It's an intermediate noMoreSplit event, notify subtask to deal with this event.
+        callInCoordinatorThread(
+                () -> {
+                    subtaskHasNoMoreSplits[subtask] = false;

Review Comment:
   yes, no need to set false. i delete it. thanks.



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on PR #21464:
URL: https://github.com/apache/flink/pull/21464#issuecomment-1364967557

   @flinkbot run azure
   


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] zhuzhurk commented on a diff in pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
zhuzhurk commented on code in PR #21464:
URL: https://github.com/apache/flink/pull/21464#discussion_r1057088280


##########
flink-runtime/src/main/java/org/apache/flink/runtime/source/coordinator/SourceCoordinatorContext.java:
##########
@@ -289,6 +290,20 @@ public void signalNoMoreSplits(int subtask) {
                 "Failed to send 'NoMoreSplits' to reader " + subtask);
     }
 
+    @Override
+    public void signalIntermediateNoMoreSplits(int subtask) {
+        checkSubtaskIndex(subtask);
+
+        // It's an intermediate noMoreSplit event, notify subtask to deal with this event.
+        callInCoordinatorThread(
+                () -> {
+                    subtaskHasNoMoreSplits[subtask] = false;

Review Comment:
   In my understanding, it should be `false` initially and set to `true` when on `signalNoMoreSplits(int)`. When failover happens, the value will be reset to `false`. Seems there is no need for `signalIntermediateNoMoreSplits(int)` to do the reset.



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] zhuzhurk commented on a diff in pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
zhuzhurk commented on code in PR #21464:
URL: https://github.com/apache/flink/pull/21464#discussion_r1055064773


##########
flink-core/src/main/java/org/apache/flink/api/connector/source/SplitEnumeratorContext.java:
##########
@@ -126,6 +126,16 @@ default void assignSplit(SplitT split, int subtask) {
      */
     void signalNoMoreSplits(int subtask);
 
+    /**
+     * Signals a subtask that it will not receive split for current source, but it will receive
+     * split for next sources. A common scenario is HybridSource. This indicates that task not truly
+     * read finished.
+     *
+     * @param subtask The index of the operator's parallel subtask that shall be signaled it will
+     *     receive splits later.
+     */
+    default void signalIntermediateNoMoreSplits(int subtask) {}

Review Comment:
   Let's avoid adding this method to `SplitEnumeratorContext` which is a `@Public` interface.
   Intermediate noMoreSplits event is strictly related to HybridSource and is hard for users to understand or handle.
   
   I think we can just directly add the method to  `SourceCoordinatorContext`, then use `instanceOf` and type cast in `HybridSourceSplitEnumerator` to invoke this method.



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on a diff in pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on code in PR #21464:
URL: https://github.com/apache/flink/pull/21464#discussion_r1056014959


##########
flink-core/src/main/java/org/apache/flink/api/connector/source/SplitEnumeratorContext.java:
##########
@@ -126,6 +126,16 @@ default void assignSplit(SplitT split, int subtask) {
      */
     void signalNoMoreSplits(int subtask);
 
+    /**
+     * Signals a subtask that it will not receive split for current source, but it will receive
+     * split for next sources. A common scenario is HybridSource. This indicates that task not truly
+     * read finished.
+     *
+     * @param subtask The index of the operator's parallel subtask that shall be signaled it will
+     *     receive splits later.
+     */
+    default void signalIntermediateNoMoreSplits(int subtask) {}

Review Comment:
   @zhuzhurk Yes. SplitEnumeratorContext is a Public api. i add it with default method to avoid impact. We can not use `realContext instanceOf SourceCoordinatorContext` directly, HybridSourceSplitEnumerator is in flink-connector-base, SourceCoordinatorContext is in flink-runtime, how can we reference it?  using class name or add runtime dependency both are ugly.  Is there a more elegant way ?



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] flinkbot commented on pull request #21464: [FLINK-30334] Reset SourceCoordinator#handleRequestSplitEvent without violent hasNoMoreSplits check

Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #21464:
URL: https://github.com/apache/flink/pull/21464#issuecomment-1342213006

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "93544b92ead50eb7b9ab0d9728b1ad5a0531642c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "93544b92ead50eb7b9ab0d9728b1ad5a0531642c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 93544b92ead50eb7b9ab0d9728b1ad5a0531642c UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on PR #21464:
URL: https://github.com/apache/flink/pull/21464#issuecomment-1365068832

   @flinkbot run azure


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] zhuzhurk commented on a diff in pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
zhuzhurk commented on code in PR #21464:
URL: https://github.com/apache/flink/pull/21464#discussion_r1057075092


##########
flink-core/src/test/java/org/apache/flink/api/connector/source/mocks/MockSplitEnumeratorContext.java:
##########
@@ -120,7 +123,14 @@ public void assignSplits(SplitsAssignment<SplitT> newSplitAssignments) {
     }
 
     @Override
-    public void signalNoMoreSplits(int subtask) {}
+    public void signalNoMoreSplits(int subtask) {
+        subtaskHasNoMoreSplits[subtask] = true;
+    }
+
+    @Override
+    public void signalIntermediateNoMoreSplits(int subtask) {
+        subtaskHasNoMoreSplits[subtask] = false;

Review Comment:
   This method should be empty. The values should be false initially but not set to be false in this method.



##########
flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/source/hybrid/HybridSourceSplitEnumerator.java:
##########
@@ -157,7 +158,17 @@ private void sendSwitchSourceEvent(int subtaskId, int sourceIndex) {
                 LOG.debug("Restoring splits to subtask={} {}", subtaskId, splits);
                 context.assignSplits(
                         new SplitsAssignment<>(Collections.singletonMap(subtaskId, splits)));
-                context.signalNoMoreSplits(subtaskId);
+                if (context instanceof SupportsIntermediateNoMoreSplits) {

Review Comment:
   It's better to have a method to be reused, e.g. 
   ```
   private static void signalNoMoreSplits(
       SplitEnumeratorContext<HybridSourceSplit> context, 
       subtaskId, 
       int sourceIndex, 
       int sourceSize);
   ```



##########
flink-runtime/src/main/java/org/apache/flink/runtime/source/coordinator/SourceCoordinatorContext.java:
##########
@@ -289,6 +290,20 @@ public void signalNoMoreSplits(int subtask) {
                 "Failed to send 'NoMoreSplits' to reader " + subtask);
     }
 
+    @Override
+    public void signalIntermediateNoMoreSplits(int subtask) {
+        checkSubtaskIndex(subtask);
+
+        // It's an intermediate noMoreSplit event, notify subtask to deal with this event.
+        callInCoordinatorThread(
+                () -> {
+                    subtaskHasNoMoreSplits[subtask] = false;

Review Comment:
   Why is it needed to be set to false?



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on PR #21464:
URL: https://github.com/apache/flink/pull/21464#issuecomment-1364874178

   > @chucheng92 F.I.Y. the community is preparing to release 1.16.1. I hope we can get this issue fixed in this release. Would you try if the suggested way can work?
   
   Yes, done with your suggested way. I have updated the pr. PTAL. thanks.


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] zhuzhurk commented on a diff in pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
zhuzhurk commented on code in PR #21464:
URL: https://github.com/apache/flink/pull/21464#discussion_r1057158451


##########
flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/source/hybrid/HybridSourceSplitEnumeratorTest.java:
##########
@@ -216,6 +216,43 @@ public void testDefaultMethodDelegation() throws Exception {
         Mockito.verify(underlyingEnumeratorSpy).handleSourceEvent(0, se);
     }
 
+    @Test
+    public void testInterceptNoMoreSplitEvent() {
+        context = new MockSplitEnumeratorContext<>(2);
+        source = HybridSource.builder(MOCK_SOURCE).addSource(MOCK_SOURCE).build();
+
+        enumerator = (HybridSourceSplitEnumerator) source.createEnumerator(context);
+        enumerator.start();
+        // mock enumerator assigns splits once all readers are registered
+        // At this time, hasNoMoreSplit check will call context.signalIntermediateNoMoreSplits
+        registerReader(context, enumerator, SUBTASK0);
+        registerReader(context, enumerator, SUBTASK1);
+        enumerator.handleSourceEvent(SUBTASK0, new SourceReaderFinishedEvent(-1));
+        enumerator.handleSourceEvent(SUBTASK1, new SourceReaderFinishedEvent(-1));
+        assertThat(context.hasNoMoreSplits(0)).isFalse();
+        assertThat(context.hasNoMoreSplits(1)).isFalse();
+        splitFromSource0 =
+                context.getSplitsAssignmentSequence().get(0).assignment().get(SUBTASK0).get(0);
+
+        // task read finished, hasNoMoreSplit check will call context.signalNoMoreSplits, this is
+        // final finished event
+        enumerator.handleSourceEvent(SUBTASK0, new SourceReaderFinishedEvent(0));
+        enumerator.handleSourceEvent(SUBTASK1, new SourceReaderFinishedEvent(0));
+        assertThat(context.hasNoMoreSplits(0)).isTrue();
+        assertThat(context.hasNoMoreSplits(1)).isTrue();
+
+        // test add splits back, then SUBTASK0 restore splitFromSource0 split
+        // reset splits assignment & previous subtaskHasNoMoreSplits flag.
+        context.getSplitsAssignmentSequence().clear();
+        Whitebox.setInternalState(context, "subtaskHasNoMoreSplits", new boolean[] {false, false});

Review Comment:
   It's better to add a method `resetNoMoreSplits(int)` in `MockSplitEnumeratorContext`.
   Instead of using reflection to do this.



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on a diff in pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on code in PR #21464:
URL: https://github.com/apache/flink/pull/21464#discussion_r1056014959


##########
flink-core/src/main/java/org/apache/flink/api/connector/source/SplitEnumeratorContext.java:
##########
@@ -126,6 +126,16 @@ default void assignSplit(SplitT split, int subtask) {
      */
     void signalNoMoreSplits(int subtask);
 
+    /**
+     * Signals a subtask that it will not receive split for current source, but it will receive
+     * split for next sources. A common scenario is HybridSource. This indicates that task not truly
+     * read finished.
+     *
+     * @param subtask The index of the operator's parallel subtask that shall be signaled it will
+     *     receive splits later.
+     */
+    default void signalIntermediateNoMoreSplits(int subtask) {}

Review Comment:
   @zhuzhurk Yes. SplitEnumeratorContext is a Public api. i add it with default method to avoid impact. We can not use `realContext instanceOf SourceCoordinatorContext` directly, HybridSourceSplitEnumerator is in flink-connector-base, SourceCoordinatorContext is in flink-runtime, how can we reference it?  using class name or add runtime dependency both are ugly.



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] zhuzhurk commented on a diff in pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
zhuzhurk commented on code in PR #21464:
URL: https://github.com/apache/flink/pull/21464#discussion_r1056106649


##########
flink-core/src/main/java/org/apache/flink/api/connector/source/SplitEnumeratorContext.java:
##########
@@ -126,6 +126,16 @@ default void assignSplit(SplitT split, int subtask) {
      */
     void signalNoMoreSplits(int subtask);
 
+    /**
+     * Signals a subtask that it will not receive split for current source, but it will receive
+     * split for next sources. A common scenario is HybridSource. This indicates that task not truly
+     * read finished.
+     *
+     * @param subtask The index of the operator's parallel subtask that shall be signaled it will
+     *     receive splits later.
+     */
+    default void signalIntermediateNoMoreSplits(int subtask) {}

Review Comment:
   I think we can add an interface in `flink-core`, e.g. 
   ```
   @Internal
   interface SupportsIntermediateNoMoreSplits {
       void signalIntermediateNoMoreSplits(int subtask);
   }
   ```
   
   `SourceCoordinatorContext` should implements it. And `HybridSourceSplitEnumerator` should check that the realContext is an instance of `SupportsIntermediateNoMoreSplits`.



##########
flink-core/src/main/java/org/apache/flink/api/connector/source/SplitEnumeratorContext.java:
##########
@@ -126,6 +126,16 @@ default void assignSplit(SplitT split, int subtask) {
      */
     void signalNoMoreSplits(int subtask);
 
+    /**
+     * Signals a subtask that it will not receive split for current source, but it will receive
+     * split for next sources. A common scenario is HybridSource. This indicates that task not truly
+     * read finished.
+     *
+     * @param subtask The index of the operator's parallel subtask that shall be signaled it will
+     *     receive splits later.
+     */
+    default void signalIntermediateNoMoreSplits(int subtask) {}

Review Comment:
   I think we can add an interface in `flink-core`, e.g. 
   ```
   @Internal
   interface SupportsIntermediateNoMoreSplits {
       void signalIntermediateNoMoreSplits(int subtask);
   }
   ```
   
   `SourceCoordinatorContext` should implement it. And `HybridSourceSplitEnumerator` should check that the realContext is an instance of `SupportsIntermediateNoMoreSplits`.



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on PR #21464:
URL: https://github.com/apache/flink/pull/21464#issuecomment-1364908830

   @flinkbot run azure


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on PR #21464:
URL: https://github.com/apache/flink/pull/21464#issuecomment-1364941930

   @zhuzhurk thanks for reviewing, i have fixed the problem you commented. PTAL.


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on pull request #21464: [FLINK-30334][runtime] Reset SourceCoordinator#handleRequestSplitEvent check logic because hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on PR #21464:
URL: https://github.com/apache/flink/pull/21464#issuecomment-1343769087

   @flinkbot run azure


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on PR #21464:
URL: https://github.com/apache/flink/pull/21464#issuecomment-1365028550

   @flinkbot run azure


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on a diff in pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on code in PR #21464:
URL: https://github.com/apache/flink/pull/21464#discussion_r1056014959


##########
flink-core/src/main/java/org/apache/flink/api/connector/source/SplitEnumeratorContext.java:
##########
@@ -126,6 +126,16 @@ default void assignSplit(SplitT split, int subtask) {
      */
     void signalNoMoreSplits(int subtask);
 
+    /**
+     * Signals a subtask that it will not receive split for current source, but it will receive
+     * split for next sources. A common scenario is HybridSource. This indicates that task not truly
+     * read finished.
+     *
+     * @param subtask The index of the operator's parallel subtask that shall be signaled it will
+     *     receive splits later.
+     */
+    default void signalIntermediateNoMoreSplits(int subtask) {}

Review Comment:
   @zhuzhurk Yes. SplitEnumeratorContext is a Public api. i add it with default method to avoid impact. We can not use `realContext instanceOf SourceCoordinatorContext` directly, HybridSourceSplitEnumerator is in flink-connector-base, SourceCoordinatorContext in is flink-runtime, how can we reference it?  using class FQDN or add runtime dependency both are ugly.  Is there a more elegant way ?



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on PR #21464:
URL: https://github.com/apache/flink/pull/21464#issuecomment-1361036625

   @zhuzhurk Hi, Can u help me to review it? thanks a lot


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on PR #21464:
URL: https://github.com/apache/flink/pull/21464#issuecomment-1364828231

   > @chucheng92 F.I.Y. the community is preparing to release 1.16.1. I hope we can get this issue fixed in this release. Would you try if the suggested way can work?
   
   Yes, almost done. I think we can catch up this release.


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on a diff in pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on code in PR #21464:
URL: https://github.com/apache/flink/pull/21464#discussion_r1056014959


##########
flink-core/src/main/java/org/apache/flink/api/connector/source/SplitEnumeratorContext.java:
##########
@@ -126,6 +126,16 @@ default void assignSplit(SplitT split, int subtask) {
      */
     void signalNoMoreSplits(int subtask);
 
+    /**
+     * Signals a subtask that it will not receive split for current source, but it will receive
+     * split for next sources. A common scenario is HybridSource. This indicates that task not truly
+     * read finished.
+     *
+     * @param subtask The index of the operator's parallel subtask that shall be signaled it will
+     *     receive splits later.
+     */
+    default void signalIntermediateNoMoreSplits(int subtask) {}

Review Comment:
   @zhuzhurk Yes. SplitEnumeratorContext is a Public api. i add it with default method to avoid impact. We can not use `realContext instanceOf SourceCoordinatorContext` directly, HybridSourceSplitEnumerator is in flink-connector-base, SourceCoordinatorContext is in flink-runtime, how can we reference it?  using reflection or add runtime dependency both are ugly.



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on PR #21464:
URL: https://github.com/apache/flink/pull/21464#issuecomment-1360990615

   @flinkbot run azure


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] zhuzhurk commented on pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
zhuzhurk commented on PR #21464:
URL: https://github.com/apache/flink/pull/21464#issuecomment-1364686045

   @chucheng92 F.I.Y. the community is preparing to release 1.16.1. I hope we can get this issue fixed in this release.
   Would you try if the suggested way can work?


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] zhuzhurk commented on pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
zhuzhurk commented on PR #21464:
URL: https://github.com/apache/flink/pull/21464#issuecomment-1365540296

   Merging.


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] zhuzhurk closed pull request #21464: [FLINK-30334][runtime] Fix noMoreSplits event handling for HybridSource

Posted by GitBox <gi...@apache.org>.
zhuzhurk closed pull request #21464: [FLINK-30334][runtime] Fix noMoreSplits event handling for HybridSource
URL: https://github.com/apache/flink/pull/21464


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on a diff in pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on code in PR #21464:
URL: https://github.com/apache/flink/pull/21464#discussion_r1057181722


##########
flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/source/hybrid/HybridSourceSplitEnumeratorTest.java:
##########
@@ -216,6 +216,43 @@ public void testDefaultMethodDelegation() throws Exception {
         Mockito.verify(underlyingEnumeratorSpy).handleSourceEvent(0, se);
     }
 
+    @Test
+    public void testInterceptNoMoreSplitEvent() {
+        context = new MockSplitEnumeratorContext<>(2);
+        source = HybridSource.builder(MOCK_SOURCE).addSource(MOCK_SOURCE).build();
+
+        enumerator = (HybridSourceSplitEnumerator) source.createEnumerator(context);
+        enumerator.start();
+        // mock enumerator assigns splits once all readers are registered
+        // At this time, hasNoMoreSplit check will call context.signalIntermediateNoMoreSplits
+        registerReader(context, enumerator, SUBTASK0);
+        registerReader(context, enumerator, SUBTASK1);
+        enumerator.handleSourceEvent(SUBTASK0, new SourceReaderFinishedEvent(-1));
+        enumerator.handleSourceEvent(SUBTASK1, new SourceReaderFinishedEvent(-1));
+        assertThat(context.hasNoMoreSplits(0)).isFalse();
+        assertThat(context.hasNoMoreSplits(1)).isFalse();
+        splitFromSource0 =
+                context.getSplitsAssignmentSequence().get(0).assignment().get(SUBTASK0).get(0);
+
+        // task read finished, hasNoMoreSplit check will call context.signalNoMoreSplits, this is
+        // final finished event
+        enumerator.handleSourceEvent(SUBTASK0, new SourceReaderFinishedEvent(0));
+        enumerator.handleSourceEvent(SUBTASK1, new SourceReaderFinishedEvent(0));
+        assertThat(context.hasNoMoreSplits(0)).isTrue();
+        assertThat(context.hasNoMoreSplits(1)).isTrue();
+
+        // test add splits back, then SUBTASK0 restore splitFromSource0 split
+        // reset splits assignment & previous subtaskHasNoMoreSplits flag.
+        context.getSplitsAssignmentSequence().clear();
+        Whitebox.setInternalState(context, "subtaskHasNoMoreSplits", new boolean[] {false, false});

Review Comment:
   @zhuzhurk thanks for your suggestion. 



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on PR #21464:
URL: https://github.com/apache/flink/pull/21464#issuecomment-1360734949

   @flinkbot run azure


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] chucheng92 commented on a diff in pull request #21464: [FLINK-30334][runtime] Fix SourceCoordinator#handleRequestSplitEvent hasNoMoreSplits check not consider the hybridsource situation

Posted by GitBox <gi...@apache.org>.
chucheng92 commented on code in PR #21464:
URL: https://github.com/apache/flink/pull/21464#discussion_r1056014959


##########
flink-core/src/main/java/org/apache/flink/api/connector/source/SplitEnumeratorContext.java:
##########
@@ -126,6 +126,16 @@ default void assignSplit(SplitT split, int subtask) {
      */
     void signalNoMoreSplits(int subtask);
 
+    /**
+     * Signals a subtask that it will not receive split for current source, but it will receive
+     * split for next sources. A common scenario is HybridSource. This indicates that task not truly
+     * read finished.
+     *
+     * @param subtask The index of the operator's parallel subtask that shall be signaled it will
+     *     receive splits later.
+     */
+    default void signalIntermediateNoMoreSplits(int subtask) {}

Review Comment:
   Yes. SplitEnumeratorContext is a Public api. i add it with default method to avoid impact. But it is indeed inappropriate here. Let me modify it. Thanks for reviewing.



##########
flink-core/src/main/java/org/apache/flink/api/connector/source/SplitEnumeratorContext.java:
##########
@@ -126,6 +126,16 @@ default void assignSplit(SplitT split, int subtask) {
      */
     void signalNoMoreSplits(int subtask);
 
+    /**
+     * Signals a subtask that it will not receive split for current source, but it will receive
+     * split for next sources. A common scenario is HybridSource. This indicates that task not truly
+     * read finished.
+     *
+     * @param subtask The index of the operator's parallel subtask that shall be signaled it will
+     *     receive splits later.
+     */
+    default void signalIntermediateNoMoreSplits(int subtask) {}

Review Comment:
   @zhuzhurk Yes. SplitEnumeratorContext is a Public api. i add it with default method to avoid impact. But it is indeed inappropriate here. Let me modify it. Thanks for reviewing.



-- 
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: issues-unsubscribe@flink.apache.org

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