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


##########
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:
   I hope the latest changes resolve your worries about this. I think there was 
a missing shutdown time comparison which is one of CoPilot's findings too.



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