Shekharrajak commented on code in PR #22357:
URL: https://github.com/apache/kafka/pull/22357#discussion_r3294052971
##########
core/src/main/java/kafka/server/share/SharePartitionManager.java:
##########
@@ -353,6 +354,36 @@ public CompletableFuture<Map<TopicIdPartition,
ShareAcknowledgeResponseData.Part
return mapAcknowledgementFutures(futures,
Optional.of(failedShareAcknowledgeMetricsHandler()));
}
+ public CompletableFuture<Map<TopicIdPartition,
ShareAcknowledgeResponseData.PartitionData>> acknowledgeTransactional(
+ String memberId,
+ String groupId,
+ long producerId,
+ short producerEpoch,
+ Map<TopicIdPartition, List<ShareAcknowledgementBatch>>
acknowledgeTopics
+ ) {
+ log.trace("Txn acknowledge request for topicIdPartitions: {} groupId:
{} producerId={}",
+ acknowledgeTopics.keySet(), groupId, producerId);
+ Map<TopicIdPartition, CompletableFuture<Throwable>> futures = new
HashMap<>();
+ acknowledgeTopics.forEach((topicIdPartition,
acknowledgePartitionBatches) -> {
+ SharePartitionKey sharePartitionKey = sharePartitionKey(groupId,
topicIdPartition);
+ SharePartition sharePartition =
partitionCache.get(sharePartitionKey);
+ if (sharePartition == null) {
+ futures.put(topicIdPartition,
CompletableFuture.completedFuture(Errors.UNKNOWN_TOPIC_OR_PARTITION.exception()));
+ return;
+ }
+ CompletableFuture<Throwable> future = new CompletableFuture<>();
+ sharePartition.stageTxnAcknowledge(memberId, producerId,
producerEpoch, acknowledgePartitionBatches)
+ .whenComplete((result, throwable) ->
future.complete(throwable));
+ futures.put(topicIdPartition, future);
+ });
+ return mapAcknowledgementFutures(futures, Optional.empty());
+ }
+
+ public void applyTxnMarker(long producerId, short producerEpoch,
TransactionResult result) {
+ log.debug("Broadcasting txn marker producerId={} epoch={} result={}",
producerId, producerEpoch, result);
+ partitionCache.values().forEach(sp -> sp.applyTxnMarker(producerId,
producerEpoch, result));
Review Comment:
iterates every SharePartition on this broker, each iterates its
InFlightStates, each checks (state == TX_PENDING && stagedProducerId ==
producerId && stagedProducerEpoch == epoch) and apply the marker for all the
share partitions.
This can be improved but InFlightState.applyTxnMarker is O(1) operation
--
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]