richardstartin commented on code in PR #8491: URL: https://github.com/apache/pinot/pull/8491#discussion_r847759869
########## pinot-core/src/main/java/org/apache/pinot/core/transport/ServerChannels.java: ########## @@ -181,24 +191,43 @@ private void sendRequest(String rawTableName, AsyncQueryResponse asyncQueryRespo } } - private void sendRequest(String rawTableName, AsyncQueryResponse asyncQueryResponse, - ServerRoutingInstance serverRoutingInstance, byte[] requestBytes) - throws Exception { + void connectWithoutLocking() + throws InterruptedException { if (_channel == null || !_channel.isActive()) { long startTime = System.currentTimeMillis(); _channel = _bootstrap.connect().sync().channel(); _brokerMetrics.setValueOfGlobalGauge(BrokerGauge.NETTY_CONNECTION_CONNECT_TIME_MS, System.currentTimeMillis() - startTime); } - long sendRequestStartTimeMs = System.currentTimeMillis(); + } + + void sendRequestWithoutLocking(String rawTableName, AsyncQueryResponse asyncQueryResponse, + ServerRoutingInstance serverRoutingInstance, byte[] requestBytes) { + long startTimeMs = System.currentTimeMillis(); _channel.writeAndFlush(Unpooled.wrappedBuffer(requestBytes)).addListener(f -> { - long requestSentLatencyMs = System.currentTimeMillis() - sendRequestStartTimeMs; + long requestSentLatencyMs = System.currentTimeMillis() - startTimeMs; _brokerMetrics.addTimedTableValue(rawTableName, BrokerTimer.NETTY_CONNECTION_SEND_REQUEST_LATENCY, requestSentLatencyMs, TimeUnit.MILLISECONDS); asyncQueryResponse.markRequestSent(serverRoutingInstance, requestSentLatencyMs); }); _brokerMetrics.addMeteredGlobalValue(BrokerMeter.NETTY_CONNECTION_REQUESTS_SENT, 1); _brokerMetrics.addMeteredGlobalValue(BrokerMeter.NETTY_CONNECTION_BYTES_SENT, requestBytes.length); } + + boolean connect() { + try { + if (_channelLock.tryLock(TRY_CONNECT_CHANNEL_LOCK_TIMEOUT_MS, TimeUnit.MILLISECONDS)) { + try { + connectWithoutLocking(); + return true; + } finally { + _channelLock.unlock(); + } + } + } catch (Exception e) { + // Ignored Review Comment: Should probably not swallow this, at least log if at debug -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org