spuru9 commented on code in PR #338:
URL:
https://github.com/apache/flink-connector-kafka/pull/338#discussion_r4718336530
##########
flink-connector-kafka/src/test/java/org/apache/flink/connector/kafka/sink/FlinkKafkaInternalProducerITCase.java:
##########
@@ -208,11 +208,10 @@ void testDoubleCommitAndAbort(boolean firstCommit,
boolean secondCommit) {
resumedProducer.abortTransaction();
}
});
- if (firstCommit == secondCommit) {
- secondOp.doesNotThrowAnyException();
- } else {
- secondOp.isInstanceOf(InvalidTxnStateException.class);
- }
+ // With Transactions V2 (KIP-890), the default since Kafka 4.0,
ending a transaction
+ // bumps the producer epoch. A producer resumed with the epoch of
the finished
+ // transaction is therefore fenced, whether it commits or aborts.
+ secondOp.isInstanceOf(ProducerFencedException.class);
Review Comment:
You're right, thanks. The resumed producer never calls `initTransactions()`
or `beginTransaction()`, so it keeps sending EndTxn v4. I restored the old
assertion. The test now runs only on the TV1 broker and is skipped on TV2, with
a pointer to FLINK-40689.
##########
flink-connector-kafka/src/test/java/org/apache/flink/connector/kafka/testutils/DockerImageVersions.java:
##########
@@ -24,8 +24,8 @@
*/
public class DockerImageVersions {
- public static final String CP_KAFKA = "confluentinc/cp-kafka:7.9.2";
- public static final String APACHE_KAFKA = "apache/kafka:4.2.0";
+ public static final String CP_KAFKA = "confluentinc/cp-kafka:8.4.1";
Review Comment:
Added. `FlinkKafkaInternalProducerITCase`, `ExactlyOnceKafkaWriterITCase`,
`KafkaTransactionLogITCase` and `KafkaSinkRecoveryITCase` now run once with
`transaction.version` 2 and once with 1, each time on a fresh broker. The
exactly-once tests in `KafkaSinkITCase` also run with 1, chained jobs only. The
version is set with `Admin#updateFeatures` in
`KafkaUtil#setTransactionVersion`, which #321 could also use for its V1 broker
instead of `CP_KAFKA`.
##########
flink-connector-kafka/src/test/java/org/apache/flink/connector/kafka/sink/ExactlyOnceKafkaWriterITCase.java:
##########
@@ -208,6 +221,16 @@ private void triggerProducerException(KafkaWriter<Integer>
writer, Properties pr
writer.write(1, SINK_WRITER_CONTEXT);
}
+ /**
+ * Waits until a record written after the first failure has failed too.
With Transactions V2,
Review Comment:
Yes, the ordering is the same. What differs is where the first failure comes
from: with TV1 it's the AddPartitionsToTxn response, which records the error
before any batch fails. I reworded the Javadoc.
##########
flink-connector-kafka/src/test/java/org/apache/flink/connector/kafka/sink/KafkaTransactionLog.java:
##########
@@ -43,7 +43,10 @@
*/
class KafkaTransactionLog {
- private static final int SUPPORTED_KAFKA_SCHEMA_VERSION = 0;
+ private static final int MAX_KEY_SCHEMA_VERSION = 0;
+ // Brokers with Transactions V2 (KIP-890), the default since Kafka 4.0,
write version 1. It
Review Comment:
Right, fixed the comment.
--
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]