Repository navigation
Conversation
EnvUtils.listPortOccupationUnix() parses the output of "lsof -iTCP -sTCP:LISTEN,TIME_WAIT -P -n" and took the local address from column 9. A line splits into 10 columns, though, and column 9 is the state, e.g. "(LISTEN)": java 1234 user 77u IPv6 0x1a2b 0t0 TCP 127.0.0.1:6667 (LISTEN) 0 1 2 3 4 5 6 7 8 9 So no line ever matched, and the method always returned an empty map on Linux and macOS. As a result: - searchAvailablePorts() handed out ports that another process was already listening on, and the node failed to start with "Could not create ServerSocket ... Address already in use"; - the PORT_OCCUPIED handling in AbstractEnv.handleProcessStatus() never found the node holding a port, so it never restarted it. Read the address from column 8. The Windows variant (netstat) was already correct.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #19070 +/- ##
============================================
- Coverage 48.05% 48.05% -0.01%
Complexity 604 604
============================================
Files 5572 5572
Lines 410195 410195
Branches 54112 54112
============================================
- Hits 197124 197112 -12
- Misses 213071 213083 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Problem
On Linux and macOS, the IT framework never detects ports that are already in use.
EnvUtils.searchAvailablePorts()then hands out ports another process listens on, and a node fails to start:The test then fails in
setUpwith "After 30 times retry, the cluster status check failed: ... Empty configNode set". On my machine this hit two ITs in one SimpleIT/TableSimpleIT run, because another local process was listening on 127.0.0.1:16490.Cause
listPortOccupationUnix()parseslsof -iTCP -sTCP:LISTEN,TIME_WAIT -P -nand takes the local address from column 9. A line splits into 10 columns, and column 9 is the state:"(LISTEN)".endsWith(":" + port)is never true, so the method always returns an empty map. This also disables thePORT_OCCUPIEDhandling inAbstractEnv.handleProcessStatus(), which uses the same method to find and restart a node that holds a port.Fix
Read the address from column 8. The Windows variant (
netstat -aon -p tcp, address in column 1) was already correct. A Javadoc line shows the column layout.Verification
The layout is the same on both platforms:
... TCP 127.0.0.1:16490 (LISTEN), 10 columns.... TCP 127.0.0.1:6667 (LISTEN)and... TCP [::1]:6668 (LISTEN), 10 columns, address in column 8.Called
EnvUtils.listPortOccupationUnix(...)directly on macOS, on master and with this change:{}{16490=<pid>}{}{15292=<pid>}{}{}spotless:checkpasses forintegration-test.IT runs with this change, on macOS:
EdgeIT(7 tests) andIoTDBWithoutNullAllFilterIT(SimpleIT, 11 tests, 5 skipped) pass.This PR has:
Key changed/added classes (or packages if there are too many classes) in this PR
integration-test/src/main/java/org/apache/iotdb/it/env/cluster/EnvUtils.java🤖 Generated with Claude Code