This is an automated email from the ASF dual-hosted git repository.
chrisdutz pushed a commit to branch fix/it-lsof-port-column
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/fix/it-lsof-port-column by
this push:
new 8627538928f [IT] Read the address column of lsof when checking port
occupation
8627538928f is described below
commit 8627538928f64df8f5085efcd50c86b14861c984
Author: Christofer Dutz <[email protected]>
AuthorDate: Sun Nov 1 21:50:18 2026 +0100
[IT] Read the address column of lsof when checking port occupation
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.
---
.../src/main/java/org/apache/iotdb/it/env/cluster/EnvUtils.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git
a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/EnvUtils.java
b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/EnvUtils.java
index b69e86c12bd..56393827005 100644
---
a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/EnvUtils.java
+++
b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/EnvUtils.java
@@ -175,12 +175,15 @@ public class EnvUtils {
/**
* List occupied port and the associated pid on Unix.
*
+ * <p>A line of the lsof output splits into 10 columns, e.g. {@code java
1234 user 77u IPv6 0x1a2b
+ * 0t0 TCP 127.0.0.1:6667 (LISTEN)}. The address is in column 8 and the
state in column 9.
+ *
* @param ports ports to be checked
* @return (occupiedPort, pid) pairs
*/
public static Map<Integer, Long> listPortOccupationUnix(final List<Integer>
ports)
throws IOException {
- return listPortOccupation(ports, "lsof -iTCP -sTCP:LISTEN,TIME_WAIT -P
-n", 10, 9, 1);
+ return listPortOccupation(ports, "lsof -iTCP -sTCP:LISTEN,TIME_WAIT -P
-n", 10, 8, 1);
}
private static Pair<Integer, Integer> getClusterNodesNum(final int index) {