-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
KAFKA-18274: Failed to restart controller in testing due to closed socket channel [2/2] #18337
base: trunk
Are you sure you want to change the base?
KAFKA-18274: Failed to restart controller in testing due to closed socket channel [2/2] #18337
Conversation
if (socketChannel != null && socketChannel.isOpen()) { | ||
return socketChannel; | ||
} else if (socketChannel != null) { | ||
// bind the server socket with same port | ||
socketAddress = new InetSocketAddress(socketAddress.getHostString(), socketChannel.socket().getLocalPort()); | ||
socketChannel = ServerSocketFactory.INSTANCE.openServerSocket( | ||
listenerName, | ||
socketAddress, | ||
listenBacklogSize, | ||
recvBufferSize); | ||
return socketChannel; | ||
} |
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.
Please combine the null checks.
Instead of checking for socketChannel != null
twice, we can combine them into a single block that handles the non-null case.
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.
Nice catch. Thanks!
@peterxcli please fix the conflicts |
89f5780
to
687af35
Compare
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.
LGTM
Failed tests are tracked by: |
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.
@peterxcli thanks for this patch. two minor comments remaining. Please take a look
if (socketChannel.isOpen()) { | ||
return socketChannel; | ||
} | ||
// bind the server socket with same port |
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.
Could you please add comments to explain the use cases of binding the same port?
|
||
ControllerServer controller = cluster.controllers().values().iterator().next(); | ||
controller.shutdown(); | ||
controller.awaitShutdown(); |
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.
Could you please add test for broker as well? the fix should works for broker, right?
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.
Enable controller to restart with the same port in ClusterTest.
Tests
In the newly added test
testKRaftIsolatedControllerRestart
, if we don't have the corresponding changes inPreboundSocketFactoryManager
then the admin will keep retrying connect to the restarted controller, cause the controller's port has changed.