bitflicker64 opened a new pull request, #3105:
URL: https://github.com/apache/hugegraph/pull/3105
## Purpose of the PR
Fix a startup hang in kind/Kubernetes environments caused by `lsof` scanning
an enormous file descriptor table.
## Main Changes
The startup script (`start-hugegraph.sh`) calls `check_port` before
launching Java to verify the target port is free. The original implementation
used `lsof -i :PORT`.
In kind/k8s pods, `ulimit -n` (max open file descriptors) can be set to ~1
billion. `lsof` tries to scan all possible file descriptors up to that limit,
pegging CPU at 100% and never completing — blocking server startup entirely.
Plain Docker with the same image is unaffected because its default `ulimit -n`
is ~1024.
**`hugegraph-server/.../util.sh`**
- Replace `lsof -i :PORT` with Bash's `/dev/tcp` pseudo-device. This checks
whether the port accepts a TCP connection without invoking `lsof`, avoiding the
expensive file-descriptor scan under very large `nofile` limits and removing
the dependency on the external `lsof` binary.
**`hugegraph-pd/.../util.sh` and `hugegraph-store/.../util.sh`**
- Remove `check_port` entirely — it is never called by the PD or Store
startup scripts (confirmed with maintainer).
- Fix `command_available`: the original implementation used command
substitution while redirecting the command output to `/dev/null`, so the
substitution always produced an empty result. This caused the function to
report commands as available regardless of whether they existed, affecting
`get_ip` and `download`.
## Verifying these changes
- [ ] Already covered by existing tests, such as *(please modify tests
here)*.
- [x] Need tests and can be verified as follows:
- Start HugeGraph Server in a kind/Kubernetes pod with `ulimit -n` set
to a large value (e.g. 1e9). Confirm the server starts successfully without
hanging at the port check step.
## Does this PR potentially affect the following parts?
- [x] Nope
## Documentation Status
- [x] `Doc - No Need`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]