apoorvmittal10 commented on code in PR #23703:
URL: https://github.com/apache/kafka/pull/23703#discussion_r4540493871


##########
clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:
##########
@@ -742,8 +751,14 @@ public void close(Duration timeout) {
         long now = time.milliseconds();
         long newHardShutdownTimeMs = now + waitTimeMs;
         long prev = INVALID_SHUTDOWN_TIME;
-        
clientTelemetryReporter.ifPresent(ClientTelemetryReporter::initiateClose);
-        metrics.close();
+        // Ask the telemetry reporter to make its final, terminating metrics 
push. The push is sent by the
+        // I/O thread, which waits for it to compelte, bounded by the request 
timeout, before exiting. The
+        // metrics and their reporters and closed by the I/O thread as it 
exits, so that the reporter is
+        // not closed before the push has been made.
+        clientTelemetryReporter.ifPresent(reporter -> {
+            reporter.initiateClose();
+            
terminatingTelemetryPushDeadlineMs.compareAndSet(INVALID_SHUTDOWN_TIME, now + 
requestTimeoutMs);

Review Comment:
   Can this additional wait halt the client to close longer? I am worried if 
issue like this might occur again: https://github.com/apache/kafka/pull/17431



##########
clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java:
##########
@@ -122,6 +123,9 @@ public class Sender implements Runnable {
     /* all the state related to transactions, in particular the producer id, 
producer epoch, and sequence numbers */
     private final TransactionManager transactionManager;
 
+    /* the client telemetry sender, if telemetry is enabled, whose terminating 
push is awaited at close */
+    private final ClientTelemetrySender clientTelemetrySender;

Review Comment:
   Instead of adding `clientTelemetrySender` here which is only required while 
closing, we might can achieve same by sending a final call in 
NetworkClient.TelemetrySender while closing. That can also check if the stick 
node does exist if not then we should avoid creating new connection.



-- 
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]

Reply via email to