lindong28 opened a new pull request #17342:
URL: https://github.com/apache/flink/pull/17342


   ## What is the purpose of the change
   
   The test `KafkaSourceReaderTest.testOffsetCommitOnCheckpointComplete` is 
flaky according to the test failure history in 
[FLINK-20928](https://issues.apache.org/jira/browse/FLINK-20928). This PR 
attempts to fix this flaky test.
   
   ## Brief change log
   
   Here are the problems with the existing code that could explain why the test 
is flaky:
   
   1) The test calls `KafkaSourceReader.notifyCheckpointComplete(...)` once and 
expects the offset commit to be successful. 
   2) However, `KafkaSourceReader.notifyCheckpointComplete(...)` does not 
guarantee the offset commit to be successfully. This is because it calls 
`KafkaConsumer.commitAsync(...)` just once and won't retry even if the commit 
fails with an retriable exception.
   3) During in the test, if the coordinator is temporarily unavailable due to 
e.g. coordinator movement or network disconnection, the test will fail due to 
TimeoutException.
   
   This PR made the following changes to address the issues described above:
   
   1) Updated `KafkaSourceReader.notifyCheckpointComplete` so that it can be 
called multiple times with the same `checkpointId`.
   2) Updated `CommonTestUtils.waitUtil(...)` to support user-specified sleep 
time. Previously `waitUtil(...)` hardcodes the sleep time to be 1 ms.
   3) Updated `KafkaSourceReaderTest.testOffsetCommitOnCheckpointComplete` to 
retry `KafkaSourceReader.notifyCheckpointComplete` once per second until either 
the offset commit has completed or the max wait time has been reached.
   
   The PR additionally improves the efficiency of 
`KafkaSourceFetcherManager.commitOffsets` by making the following changes:
   4) Updated `KafkaSourceFetcherManager.commitOffsets` so that it will use an 
existing SplitFetcher, instead of creating a new one, if there is any 
SplitFetcher available in the `fetchers`.
   
   
   ## Verifying this change
   
   The test `KafkaSourceReaderTest#testOffsetCommitOnCheckpointComplete` could 
consistently pass across 200 runs.
   
   ## 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/Mesos, 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? (no)


-- 
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