You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ce...@apache.org on 2023/07/12 15:45:56 UTC
[kafka] branch trunk updated: KAFKA-14938: Fixing flaky test testConnectorBoundary (#13646)
This is an automated email from the ASF dual-hosted git repository.
cegerton pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new d114d8e29ca KAFKA-14938: Fixing flaky test testConnectorBoundary (#13646)
d114d8e29ca is described below
commit d114d8e29ca3b8b80bbb4ea693f2a772a0e9b7d9
Author: Sambhav Jain <67...@users.noreply.github.com>
AuthorDate: Wed Jul 12 21:15:49 2023 +0530
KAFKA-14938: Fixing flaky test testConnectorBoundary (#13646)
Reviewers: Sagar Rao <sa...@gmail.com>, Yash Mayya <ya...@gmail.com>,
Sudesh Wasnik <sw...@confluent.io>, Chris Egerton <ch...@aiven.io>
---
.../integration/ExactlyOnceSourceIntegrationTest.java | 17 ++++++++++-------
.../connect/integration/MonitorableSourceConnector.java | 4 ++++
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/connect/runtime/src/test/java/org/apache/kafka/connect/integration/ExactlyOnceSourceIntegrationTest.java b/connect/runtime/src/test/java/org/apache/kafka/connect/integration/ExactlyOnceSourceIntegrationTest.java
index bacfd311f5d..21cd7340653 100644
--- a/connect/runtime/src/test/java/org/apache/kafka/connect/integration/ExactlyOnceSourceIntegrationTest.java
+++ b/connect/runtime/src/test/java/org/apache/kafka/connect/integration/ExactlyOnceSourceIntegrationTest.java
@@ -394,9 +394,12 @@ public class ExactlyOnceSourceIntegrationTest {
props.put(MESSAGES_PER_POLL_CONFIG, MESSAGES_PER_POLL);
props.put(MAX_MESSAGES_PER_SECOND_CONFIG, MESSAGES_PER_SECOND);
- // expect all records to be consumed and committed by the connector
- connectorHandle.expectedRecords(MINIMUM_MESSAGES);
- connectorHandle.expectedCommits(MINIMUM_MESSAGES);
+ // the connector aborts some transactions, which causes records that it has emitted (and for which
+ // SourceTask::commitRecord has been invoked) to be invisible to consumers; we expect the task to
+ // emit at most 233 records in total before 100 records have been emitted as part of one or more
+ // committed transactions
+ connectorHandle.expectedRecords(233);
+ connectorHandle.expectedCommits(233);
// start a source connector
connect.configureConnector(CONNECTOR_NAME, props);
@@ -413,10 +416,10 @@ public class ExactlyOnceSourceIntegrationTest {
consumerProps.put(ConsumerConfig.ISOLATION_LEVEL_CONFIG, "read_committed");
// consume all records from the source topic or fail, to ensure that they were correctly produced
ConsumerRecords<byte[], byte[]> sourceRecords = connect.kafka().consumeAll(
- CONSUME_RECORDS_TIMEOUT_MS,
- Collections.singletonMap(ConsumerConfig.ISOLATION_LEVEL_CONFIG, "read_committed"),
- null,
- topic
+ CONSUME_RECORDS_TIMEOUT_MS,
+ Collections.singletonMap(ConsumerConfig.ISOLATION_LEVEL_CONFIG, "read_committed"),
+ null,
+ topic
);
assertTrue("Not enough records produced by source connector. Expected at least: " + MINIMUM_MESSAGES + " + but got " + sourceRecords.count(),
sourceRecords.count() >= MINIMUM_MESSAGES);
diff --git a/connect/runtime/src/test/java/org/apache/kafka/connect/integration/MonitorableSourceConnector.java b/connect/runtime/src/test/java/org/apache/kafka/connect/integration/MonitorableSourceConnector.java
index 88fdb5a7d21..7643fa188a0 100644
--- a/connect/runtime/src/test/java/org/apache/kafka/connect/integration/MonitorableSourceConnector.java
+++ b/connect/runtime/src/test/java/org/apache/kafka/connect/integration/MonitorableSourceConnector.java
@@ -275,13 +275,17 @@ public class MonitorableSourceConnector extends SampleSourceConnector {
if (context.transactionContext() == null || seqno != nextTransactionBoundary) {
return;
}
+ long transactionSize = nextTransactionBoundary - priorTransactionBoundary;
+
// If the transaction boundary ends on an even-numbered offset, abort it
// Otherwise, commit
boolean abort = nextTransactionBoundary % 2 == 0;
calculateNextBoundary();
if (abort) {
+ log.info("Aborting transaction of {} records", transactionSize);
context.transactionContext().abortTransaction(record);
} else {
+ log.info("Committing transaction of {} records", transactionSize);
context.transactionContext().commitTransaction(record);
}
}