aeolus811tw opened a new pull request, #70:
URL: https://github.com/apache/flink-connector-kafka/pull/70
<!--
*Thank you very much for contributing to Apache Flink - we are happy that
you want to help us improve Flink. To help the community review your
contribution in the best possible way, please go through the checklist below,
which will get the contribution into a shape in which it can be best reviewed.*
*Please understand that we do not do this to make contributions to Flink a
hassle. In order to uphold a high standard of quality for code contributions,
while at the same time managing a large number of contributions, we need
contributors to prepare the contributions well, and give reviewers enough
contextual information for the review. Please also understand that
contributions that do not follow this guide will take longer to review and thus
typically be picked up with lower priority by the community.*
## Contribution Checklist
-->
## What is the purpose of the change
To address the current flow of KafkaProducer having exact same behavior for
`DeliveryGuarantee.NONE` and `DeliveryGuarantee.AT_LEAST_ONCE`
It is based on the understanding that the existing flush performed on
producer via `prepareSnapshotPreBarrier` and the actual checkpoint completion
on commit has a very rare race condition where there could be data being
invoked via processElement after the PreBarrier flush, and if KafkaProducer is
having retry on a batched data that has yet thrown any error, upon job failure
(caused by broker) will cause the batched data to never be committed, and since
checkpoint was successful, these data will be lost.
This PR address the issue by enabling AT_LEAST_ONCE to have an opportunity
to flush again when commit is happening when needed to avoid this issue. This
is to ensure at the end of the checkpoint cycle, producer will definitely have
no data left in its buffer.
Please comment or verify on the above understanding.
## Brief change log
- *add variable `hasRecordsInBuffer` to `FlinkKafkaInternalProducer` and
will be set when send/flush/close are called
- *add variable `transactional` to `KafkaCommittable` to track whether a
committable is transactional or not
- *add new constructor to `KafkaCommittable` for Unit Test backward
compatibility
- *have `prepareCommit` also return list of commitable for
DeliveryGuarantee.AT_LEAST_ONCE in `prepareCommit()`
- *have `KafkaCommitter` check the new transactional value on
`KafkaCommittable` to perform `commitTransaction()` to preserve original
EXACTLY_ONCE pathway
## Verifying this change
This change added tests and can be verified as follows:
- *Added second flush test to test this particular special case (where
producer.send was invoked after a flush)*
- *Manually verified the job runs correctly with this change in existing
cluster*
## 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]