protected void doCloseChannelDueToUnrecoverableError(Throwable cause) { // We should now be in the channel's event loop. Do a final check to make sure the call is still active // since it could have closed while we were waiting to run on the event loop. if (callActiveHolder.heldObject) { runnableWithTracingAndMdc( () -> logger.error("Closing StreamingChannel due to unrecoverable error. " + "channel_id={}, unrecoverable_error={}", channel.toString(), String.valueOf(cause) ), distributedTracingSpanStack, distributedTracingMdcInfo ).run(); // Mark the channel as broken so it will be closed and removed from the pool when it is returned. markChannelAsBroken(channel); // Release it back to the pool if possible/necessary so the pool can do its usual cleanup. releaseChannelBackToPoolIfCallIsActive( channel, pool, callActiveHolder, "closing StreamingChannel due to unrecoverable error: " + String.valueOf(cause), distributedTracingSpanStack, distributedTracingMdcInfo ); // No matter what the cause is we want to make sure the channel is closed. channel.close(); } else { logger.debug("The call deactivated before we could close the StreamingChannel. Therefore there's " + "nothing to do for this unrecoverable error as any necessary cleanup has already been " + "done. ignored_unrecoverable_error={}", cause.toString()); } } }
protected void doCloseChannelDueToUnrecoverableError(Throwable cause) { // We should now be in the channel's event loop. Do a final check to make sure the call is still active // since it could have closed while we were waiting to run on the event loop. if (callActiveHolder.heldObject) { runnableWithTracingAndMdc( () -> logger.error("Closing StreamingChannel due to unrecoverable error. " + "channel_id={}, unrecoverable_error={}", channel.toString(), String.valueOf(cause) ), distributedTracingSpanStack, distributedTracingMdcInfo ).run(); // Mark the channel as broken so it will be closed and removed from the pool when it is returned. markChannelAsBroken(channel); // Release it back to the pool if possible/necessary so the pool can do its usual cleanup. releaseChannelBackToPoolIfCallIsActive( channel, pool, callActiveHolder, "closing StreamingChannel due to unrecoverable error: " + String.valueOf(cause), distributedTracingSpanStack, distributedTracingMdcInfo ); // No matter what the cause is we want to make sure the channel is closed. channel.close(); } else { logger.debug("The call deactivated before we could close the StreamingChannel. Therefore there's " + "nothing to do for this unrecoverable error as any necessary cleanup has already been " + "done. ignored_unrecoverable_error={}", cause.toString()); } } }
protected static void markChannelBrokenAndLogInfoIfHttpClientCodecStateIsNotZero(Channel ch, String callContextForLogs) { HttpClientCodec currentCodec = (HttpClientCodec) ch.pipeline().get(HTTP_CLIENT_CODEC_HANDLER_NAME); if (currentCodec != null) { int currentHttpClientCodecInboundState = determineHttpClientCodecInboundState(currentCodec); if (currentHttpClientCodecInboundState != 0) { boolean channelAlreadyBroken = channelIsMarkedAsBeingBroken(ch); logger.warn( "HttpClientCodec inbound state was not 0. The channel will be marked as broken so it won't be " + "used. bad_httpclientcodec_inbound_state={}, channel_already_broken={}, channel_id={}, " + "call_context=\"{}\"", currentHttpClientCodecInboundState, channelAlreadyBroken, ch.toString(), callContextForLogs ); markChannelAsBroken(ch); } else { int currentHttpClientCodecOutboundState = determineHttpClientCodecOutboundState(currentCodec); if (currentHttpClientCodecOutboundState != 0) { boolean channelAlreadyBroken = channelIsMarkedAsBeingBroken(ch); logger.warn( "HttpClientCodec outbound state was not 0. The channel will be marked as broken so it won't be " + "used. bad_httpclientcodec_outbound_state={}, channel_already_broken={}, channel_id={}, " + "call_context=\"{}\"", currentHttpClientCodecOutboundState, channelAlreadyBroken, ch.toString(), callContextForLogs ); markChannelAsBroken(ch); } } } }
protected static void markChannelBrokenAndLogInfoIfHttpClientCodecStateIsNotZero(Channel ch, String callContextForLogs) { HttpClientCodec currentCodec = (HttpClientCodec) ch.pipeline().get(HTTP_CLIENT_CODEC_HANDLER_NAME); if (currentCodec != null) { int currentHttpClientCodecInboundState = determineHttpClientCodecInboundState(currentCodec); if (currentHttpClientCodecInboundState != 0) { boolean channelAlreadyBroken = channelIsMarkedAsBeingBroken(ch); logger.warn( "HttpClientCodec inbound state was not 0. The channel will be marked as broken so it won't be " + "used. bad_httpclientcodec_inbound_state={}, channel_already_broken={}, channel_id={}, " + "call_context=\"{}\"", currentHttpClientCodecInboundState, channelAlreadyBroken, ch.toString(), callContextForLogs ); markChannelAsBroken(ch); } else { int currentHttpClientCodecOutboundState = determineHttpClientCodecOutboundState(currentCodec); if (currentHttpClientCodecOutboundState != 0) { boolean channelAlreadyBroken = channelIsMarkedAsBeingBroken(ch); logger.warn( "HttpClientCodec outbound state was not 0. The channel will be marked as broken so it won't be " + "used. bad_httpclientcodec_outbound_state={}, channel_already_broken={}, channel_id={}, " + "call_context=\"{}\"", currentHttpClientCodecOutboundState, channelAlreadyBroken, ch.toString(), callContextForLogs ); markChannelAsBroken(ch); } } } }
markChannelAsBroken(ch); pool.release(ch); markChannelAsBroken(ch); pool.release(ch); markChannelAsBroken(ch); pool.release(ch);
markChannelAsBroken(ch); pool.release(ch); markChannelAsBroken(ch); pool.release(ch); markChannelAsBroken(ch); pool.release(ch);