dang-stripe commented on code in PR #17466:
URL: https://github.com/apache/pinot/pull/17466#discussion_r2669530074


##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/service/dispatch/QueryDispatcher.java:
##########
@@ -555,6 +555,25 @@ private DispatchClient 
getOrCreateDispatchClient(QueryServerInstance queryServer
     return _dispatchClientMap.computeIfAbsent(hostnamePort, k -> new 
DispatchClient(hostname, port, _tlsConfig));
   }
 
+  /**
+   * Resets the DispatchClient for a server, clearing stale gRPC channel state 
and creating a fresh connection.
+   * Call this when a server is re-enabled to bypass gRPC's exponential 
backoff on reconnection which will cause
+   * requests to fast fail.
+   */
+  public void resetDispatchClient(ServerInstance serverInstance) {
+    String hostname = serverInstance.getHostname();
+    int port = serverInstance.getQueryServicePort();
+    String hostnamePort = String.format("%s_%d", hostname, port);
+    _dispatchClientMap.compute(hostnamePort, (key, oldClient) -> {
+      LOGGER.info("Resetting DispatchClient for server: {}", 
serverInstance.getInstanceId());
+      if (oldClient != null) {
+        LOGGER.info("Shutting down old channel for server: {}", 
serverInstance.getInstanceId());
+        oldClient.getChannel().shutdown();

Review Comment:
   ah yes, didn't realize this was non-blocking. looks like there's also a 
[`resetConnectBackoff`](https://grpc.github.io/grpc-java/javadoc/io/grpc/ManagedChannel.html#resetConnectBackoff())
 on the channel API which would be less disruptive. let me try that first.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to