huangdongfa commented on issue #1748: bookkeeper 4.4.0, PerChannelBookieClient connecting to bookie does not excute operationComplete() URL: https://github.com/apache/bookkeeper/issues/1748#issuecomment-428461858 this is stack file, [bookkeeper-client.jstack.txt](https://github.com/apache/bookkeeper/files/2463469/bookkeeper-client.jstack.txt) relevant code, look like netty don't callback operationComplete(): ```java private void connect() { LOG.info("Connecting to bookie: {}", addr); // Set up the ClientBootStrap so we can create a new Channel connection // to the bookie. ClientBootstrap bootstrap = new ClientBootstrap(channelFactory); bootstrap.setPipelineFactory(this); bootstrap.setOption("tcpNoDelay", conf.getClientTcpNoDelay()); bootstrap.setOption("keepAlive", true); bootstrap.setOption("connectTimeoutMillis", conf.getClientConnectTimeoutMillis()); bootstrap.setOption("child.sendBufferSize", conf.getClientSendBufferSize()); bootstrap.setOption("child.receiveBufferSize", conf.getClientReceiveBufferSize()); bootstrap.setOption("writeBufferLowWaterMark", conf.getClientWriteBufferLowWaterMark()); bootstrap.setOption("writeBufferHighWaterMark", conf.getClientWriteBufferHighWaterMark()); SocketAddress bookieAddr = addr.getSocketAddress(); if (channelFactory instanceof LocalClientChannelFactory) { bookieAddr = addr.getLocalAddress(); } ChannelFuture future = bootstrap.connect(bookieAddr); future.addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { LOG.info("Channel connected ({}) {}", future.isSuccess(), future.getChannel()); int rc; Queue<GenericCallback<PerChannelBookieClient>> oldPendingOps; synchronized (PerChannelBookieClient.this) { if (future.isSuccess() && state == ConnectionState.CONNECTING) { LOG.info("Successfully connected to bookie: {}", future.getChannel()); rc = BKException.Code.OK; channel = future.getChannel(); state = ConnectionState.CONNECTED; } else if (future.isSuccess() && (state == ConnectionState.CLOSED || state == ConnectionState.DISCONNECTED)) { LOG.warn("Closed before connection completed, clean up: {}, current state {}", future.getChannel(), state); closeChannel(future.getChannel()); rc = BKException.Code.BookieHandleNotAvailableException; channel = null; } else if (future.isSuccess() && state == ConnectionState.CONNECTED) { LOG.debug("Already connected with another channel({}), so close the new channel({})", channel, future.getChannel()); closeChannel(future.getChannel()); return; // pendingOps should have been completed when other channel connected } else { LOG.error("Could not connect to bookie: {}/{}, current state {} : ", new Object[] { future.getChannel(), addr, state, future.getCause() }); rc = BKException.Code.BookieHandleNotAvailableException; closeChannel(future.getChannel()); channel = null; if (state != ConnectionState.CLOSED) { state = ConnectionState.DISCONNECTED; } } // trick to not do operations under the lock, take the list // of pending ops and assign it to a new variable, while // emptying the pending ops by just assigning it to a new // list oldPendingOps = pendingOps; pendingOps = new ArrayDeque<GenericCallback<PerChannelBookieClient>>(); } for (GenericCallback<PerChannelBookieClient> pendingOp : oldPendingOps) { completeOperation(pendingOp, rc); } } }); } ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
