You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "fapaul (via GitHub)" <gi...@apache.org> on 2024/10/08 14:55:07 UTC
Re: [PR] [FLINK-36441] Ensure producers are not leaked [flink-connector-kafka]
fapaul commented on code in PR #126:
URL: https://github.com/apache/flink-connector-kafka/pull/126#discussion_r1792038018
##########
flink-connector-kafka/src/main/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaProducer.java:
##########
@@ -1246,8 +1230,18 @@ private Set<String> generateNewTransactionalIds() {
}
@Override
- protected void finishRecoveringContext(
- Collection<FlinkKafkaProducer.KafkaTransactionState> handledTransactions) {
+ protected void finishProcessing(@Nullable KafkaTransactionState transaction) {
+ super.finishProcessing(transaction);
+ // TwoPhaseCommitSink sets transaction = null on final checkpoint and thus closing will leak
+ // the producer. For transactional producers, we track the producer in pendingTransactions.
+ if (transaction != null && !transaction.isTransactional()) {
+ transaction.producer.flush();
+ transaction.producer.close(Duration.ZERO);
+ }
+ }
Review Comment:
I feel uncomfortable merging this change as part of a "fix-tests-ticket". This is a change in production code to more or less support checkpoints-after-task-finish for the deprecated sink function.
--
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