-
Notifications
You must be signed in to change notification settings - Fork 11.7k
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
[ISSUE#4949] fix Address already in use #5000
Conversation
Hi @complone , nextPort() can only fix the issue when unit tests are running in sequential order. It would be better if we ask the OS to pick up an available port. |
Codecov Report
@@ Coverage Diff @@
## develop #5000 +/- ##
=============================================
+ Coverage 43.22% 43.30% +0.08%
- Complexity 7724 7750 +26
=============================================
Files 995 995
Lines 69067 69126 +59
Branches 9143 9159 +16
=============================================
+ Hits 29852 29935 +83
+ Misses 35469 35434 -35
- Partials 3746 3757 +11
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Thank you for contributing! It seems that the only way to find an available port is try to occupy a port using 0 and release it, but this approach is not thread-safe. You could get more information from the deprecation of SocketUtils#findAvailableTcpPort |
No, we should not use this approach. Modify the main source code to accept a configured listening port |
I agree with that. |
cc @lizhanhui @aaron-ai I think such changes are in line with expectations. In fact, the default value of nettyServerConfig.getListenPort is 0. We do not need to implement the method for netty port compatibility in NettyRemotingServer. |
cc @lizhanhui As shown here, if the port of nettyserver is temporarily occupied by port 0, we need to add additional logic to release port 0 in https://github.com/complone/rocketmq/tree/fix-issue4949-port But I am worried that this method is too invasive because we need to interact based on the Remoting protocol, which will cause the thread timing to be out of order. |
Read https://www.baeldung.com/cs/binding-available-ports#different-ways-to-bind-a-port
Actually, this is the standard way to run tests in parallelism. I've spent some time investigating the potential changes required, finding we indeed need a few changes to the current code and dledger dependency. I am OK with the current status of this PR now that there is no achievable solution with changes less than 10 lines |
Make sure set the target branch to
develop
What is the purpose of the change
Related to issue-4949
Fixed the port occupancy problem caused by the different order of shutdown calls
Verifying this change
Follow this checklist to help us incorporate your contribution quickly and easily. Notice,
it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR
.[ISSUE #123] Fix UnknownException when host config not exist
. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle
to make sure basic checks pass. Runmvn clean install -DskipITs
to make sure unit-test pass. Runmvn clean test-compile failsafe:integration-test
to make sure integration-test pass.