-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Log warning if initiateChannel
fails
#131520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Log warning if initiateChannel
fails
#131520
Conversation
Also account for the fact that `channelFuture.cause()` might be `null`.
Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination) |
Note that mostly we do already log a failure here much further up the stack, for instance: Lines 187 to 199 in f3a1664
elasticsearch/server/src/main/java/org/elasticsearch/cluster/coordination/Coordinator.java Lines 675 to 681 in cedcb5c
elasticsearch/server/src/main/java/org/elasticsearch/cluster/NodeConnectionsService.java Lines 340 to 344 in f1e3058
However it does seem unusual enough to deserve its own log message every time too. |
Channel channel = connectFuture.channel(); | ||
if (channel == null) { | ||
ExceptionsHelper.maybeDieOnAnotherThread(connectFuture.cause()); | ||
throw new IOException(connectFuture.cause()); | ||
final var cause = connectFuture.cause(); | ||
logger.warn(Strings.format("failed to initiate channel to [%s]", node), cause); | ||
ExceptionsHelper.maybeDieOnAnotherThread(cause); | ||
throw new IOException(cause); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you need a callback. Checking null on channel might be not enough.
connectFuture.addListener(f -> if (f.isSuccess() == false) { log.error...})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We add that listener here:
Line 47 in 3504c27
addListener(connectFuture, connectContext); |
I don't think we want to log every such failure, and definitely not at error
. The logging we have today is enough for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait sorry I get what you mean: if channel == null
we should still wait for connectFuture
to complete before logging the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. addListener(connectFuture, connectContext);
should be enough. if (channel == null)
block is confusing, channel is undefined until future is resolved. We should pass only connectFuture, not channel, to the Netty4TcpChannel, once connectFuture is resolved Netty4TcpChannel should update it's own channel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
channel is undefined
I meant there are few steps that can go wrong - channel initialization and registration and failures are dispatched at different thread either event-loop or global-executor. In all cases channel would be closed forcibly. But using channel that failed to initialize means we don't have our handlers attached.
Also account for the fact that
channelFuture.cause()
might benull
.