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

   ## What is the purpose of the change
   
   This patch changes the `SplitFetcher` in the base implementation of the new 
source to delay the closure of `SplitReader` to until all the previous emitted 
records are processed. This is because some of the previously emitted records 
may have not been processed by the main thread when the SplitFetcher is 
shutting down. In that case, closing the `SplitReader` may corrupt those 
unprocessed records.
   
   This patch adds a package private method to the `SplitFetcher` which is not 
exposed to the end user. And the public API signature and behavior exposed to 
the end users does not change. Personally I feel it it not necessary to have a 
FLIP. But I am not opposed to have one if others feel strong.
   
   ## Brief change log
   The patch only contains one commit. It does the following:
   1. Add a countdown latch to the split fetcher. 
   2. The SplitFetcher shutdown sequence will will insert an empty batch of 
data to the element queue for synchronization purpose. The recycle() method in 
that batch will pull the countdown latch.
   3. The shutdown sequence will then block waiting for the latch to be pulled, 
and only close the `SplitReader` after that.
   
   The countdown latch is only used when a `SplitFetcher` thread is closed for 
idleness. It the `SplitFetcher` is shut down because the `SplitFetcherManager` 
is closing, it does not wait for the countdown latch, because the main thread 
will not be processing any records in that case.
   
   ## Verifying this change
   A few unit tests have been added.
   ```
   SplitFetcherManagerTest.testCloseCleansUpPreviouslyClosedFetcher()
   
SplitFetcherManagerTest.testIdleShutdownSplitFetcherWaitsUntilRecordProcessed()
   SplitFetcherTest.testShutdownWaitingForRecordsProcessing()
   ```
   
   ## 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to