Shekharrajak commented on code in PR #22357:
URL: https://github.com/apache/kafka/pull/22357#discussion_r3430589409
##########
clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ShareConsumerTransactionTest.java:
##########
@@ -433,6 +435,74 @@ public void
testTransactionalShareAckAbortAcceptWithRemoteShareCoordinator() thr
}
}
+ @ClusterTest(
+ brokers = 3,
+ serverProperties = {
+ @ClusterConfigProperty(key = "auto.create.topics.enable", value =
"false"),
+ @ClusterConfigProperty(key =
"group.share.max.partition.max.record.locks", value = "10000"),
+ @ClusterConfigProperty(key =
"group.share.partition.max.record.locks", value = "10000"),
+ @ClusterConfigProperty(key =
"group.share.record.lock.duration.ms", value = "15000"),
+ @ClusterConfigProperty(key = "offsets.topic.replication.factor",
value = "3"),
+ @ClusterConfigProperty(key =
"share.coordinator.state.topic.min.isr", value = "1"),
+ @ClusterConfigProperty(key =
"share.coordinator.state.topic.num.partitions", value = "3"),
+ @ClusterConfigProperty(key =
"share.coordinator.state.topic.replication.factor", value = "3"),
+ @ClusterConfigProperty(key = "transaction.state.log.min.isr",
value = "1"),
+ @ClusterConfigProperty(key =
"transaction.state.log.replication.factor", value = "3")
+ }
+ )
+ @Timeout(180)
+ public void
testTransactionalShareAckCommitAfterSourceLeaderFailoverWithPendingState()
throws Exception {
+ String groupId = "txn-share-recovery-commit";
+ alterShareAutoOffsetReset(groupId, "earliest");
+
+ try (Admin admin = createAdminClient()) {
+ TopicIdPartition topicIdPartition =
createTopicIdPartitionWithRemoteShareCoordinator(admin, groupId,
"txn-share-recovery-commit-topic", 0);
+ TopicPartition topicPartition = topicIdPartition.topicPartition();
+
+ try (Producer<byte[], byte[]> producer = createProducer();
+ Producer<byte[], byte[]> transactionalProducer =
createRemoteTransactionalProducer("txn-share-recovery-commit-producer")) {
+ producer.send(record(topicPartition, "pending-commit")).get();
+ producer.flush();
+
+ transactionalProducer.initTransactions();
+ transactionalProducer.partitionsFor(topicPartition.topic());
+
+ try (ShareConsumer<byte[], byte[]> shareConsumer =
createShareConsumer(
+ groupId,
+ Map.of(ConsumerConfig.SHARE_ACKNOWLEDGEMENT_MODE_CONFIG,
EXPLICIT))) {
+ shareConsumer.subscribe(Set.of(topicPartition.topic()));
+ ConsumerRecords<byte[], byte[]> records =
waitedPoll(shareConsumer, 2500L, 1);
+ ConsumerRecord<byte[], byte[]> record =
records.iterator().next();
+ assertEquals(0L, record.offset());
+ assertEquals("pending-commit", new String(record.value(),
StandardCharsets.UTF_8));
+
+ ShareGroupMetadata groupMetadata =
shareConsumer.shareGroupMetadata();
+ shareConsumer.acknowledge(record, AcknowledgeType.ACCEPT);
+ ShareAcknowledgements acknowledgements =
shareConsumer.acknowledgementsForTransaction();
+ assertFalse(acknowledgements.isEmpty());
+
+ transactionalProducer.beginTransaction();
+
transactionalProducer.sendShareAcknowledgementsToTransaction(acknowledgements,
groupMetadata);
+ }
+
+ shutdownLeaderAndWaitForNewLeader(admin, topicPartition);
+
+ try (ShareConsumer<byte[], byte[]> reloadedConsumer =
createShareConsumer(
+ groupId,
+ Map.of(ConsumerConfig.SHARE_ACKNOWLEDGEMENT_MODE_CONFIG,
EXPLICIT))) {
+ reloadedConsumer.subscribe(Set.of(topicPartition.topic()));
+ assertEquals(0,
reloadedConsumer.poll(Duration.ofMillis(1000)).count());
+
+ transactionalProducer.commitTransaction();
+
+ verifySharePartitionLag(admin, groupId, topicPartition,
0L);
+ assertEquals(0,
reloadedConsumer.poll(Duration.ofMillis(500)).count());
Review Comment:
no lag at consumer side so it is committed as acknowledged
--
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]