[Bug] Store IpUtil.getNearestAddress logs ERROR for hostname addresses and can return 127.0.0.1
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- java
- 領域
- backend, networking
調査の方向性
Start with hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/util/IpUtil.java, then inspect the calls in HeartbeatService.java and the Docker Compose and Store README examples. Reproduce the hostname and single-interface cases described in the issue before changing behavior. Done means hostnames remain unchanged without misleading ERROR logs, loopback is not selected, and the Store address examples still behave correctly.
索引モデルが issue の本文から書いたものです。
説明
Bug Type (问题类型)
logic (逻辑设计问题)
Before submit
- I have confirmed and searched that there are no similar problems in the historical issue and documents. (Searched open and closed issues and PRs for
IpUtil,getNearestAddress,getRaftAddress, "raft address hostname". #3124 is about stale DNS after Store pod replacement and does not touch this code.)
Environment (环境信息)
- Server Version: apache/hugegraph master
176fb56dd(2026-10-02). All line numbers below are on that commit. - Backend: HStore, 3 PD + 3 Store + 3 Server on kind, installed with the HugeGraph Helm chart (2026-09-22). Store logs from a 3-node k3s run on 2026-09-19 (image 1.7.0, whose
IpUtil.javais identical to master) show the same two ERROR lines once per Store start, followed byRegister Store ... successfullywith the DNS addresses unchanged. - Standalone repro:
IpUtil.javacopied unchanged from176fb56dd, compiled with JDK 17--release 11, run ineclipse-temurin:11-jre-jammy(sha256:76ffb747ad3a) on 2026-10-02. - Data Size: not relevant.
Expected & Actual behavior (期望与实际表现)
Code path
getIpAddress()(hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/util/IpUtil.java:42-56) collects everyInet4Addresson every interface. It does not skip loopback, link-local or down interfaces, so a Kubernetes pod or a bridge-network container returns two addresses:127.0.0.1and the pod or container IP.- With two or more addresses,
getNearestAddress()splits the configured host on.and callsInteger.parseInton each part (IpUtil.java:76-78). For a DNS name this throwsNumberFormatException. The catch atIpUtil.java:96-97logs it at ERROR asgetRaftAddress, got exception, For input string: "<first label>", andIpUtil.java:99returns the input unchanged. The message namesgetRaftAddress, a method that does not exist in this class. - With exactly one address,
IpUtil.java:72-74returns that address with the configured port and never looks at the configured host. Because loopback is counted, the single address is127.0.0.1when the container has no other interface.
Callers and frequency
HeartbeatService.registerStore() calls it twice, once for the gRPC address and once for the raft address (hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/HeartbeatService.java:186-187), so each registration attempt logs two ERROR lines. registerStore() runs only while the Store state is Unknown or Offline (HeartbeatService.java:126-130). It repeats until registration succeeds (retry delay 1000 ms at :69, 500 ms when PD returns id 0 at :211), and runs again after each transition to Offline (heartbeat stream closed at :203, or more than 5 consecutive heartbeats reporting Cluster_Fault, :54 and :266-273). Once the Store is Up, storeHeartbeat() (:231-279) does not call IpUtil. The log is therefore per registration attempt, not per heartbeat. A healthy Store prints the pair once per start; a Store waiting for PD prints it on every retry.
Hostname addresses are the normal setup. The bundled compose file uses them (docker/docker-compose-3pd-3store-3server.yml:165 HG_STORE_GRPC_HOST: store0, :168 HG_STORE_RAFT_ADDRESS: store0:8510), and on Kubernetes the stable address of a StatefulSet pod is its headless-service DNS name.
Repro output (Repro prints the IPv4 list, then calls IpUtil.getNearestAddress on each argument)
### docker run --network bridge --hostname hugegraph-store-0 ...
ipv4s: [eth0=192.168.215.2, lo=127.0.0.1]
[main] ERROR org.apache.hugegraph.store.util.IpUtil - getRaftAddress, got exception, For input string: "hugegraph-store-0"
hugegraph-store-0.hugegraph-store.default.svc.cluster.local:8500 -> hugegraph-store-0.hugegraph-store.default.svc.cluster.local:8500
[main] ERROR org.apache.hugegraph.store.util.IpUtil - getRaftAddress, got exception, For input string: "hugegraph-store-0"
hugegraph-store-0.hugegraph-store.default.svc.cluster.local:8510 -> hugegraph-store-0.hugegraph-store.default.svc.cluster.local:8510
10.244.1.9:8510 -> 127.0.0.1:8510
### docker run --network none --hostname hugegraph-store-0 ...
ipv4s: [lo=127.0.0.1]
hugegraph-store-0.hugegraph-store.default.svc.cluster.local:8500 -> 127.0.0.1:8500
hugegraph-store-0.hugegraph-store.default.svc.cluster.local:8510 -> 127.0.0.1:8510
10.244.1.9:8510 -> 127.0.0.1:8510
Expected
- A configured hostname is returned unchanged, without an ERROR log.
127.0.0.1is never chosen as the address the Store registers with PD.
Actual
- Two ERROR lines per registration attempt for any hostname address, naming the wrong method. The returned address is correct, so the ERROR misleads operators who are debugging a Store that does not come up.
- With one local IPv4, a hostname is silently replaced by that IP. In the repro that IP is
127.0.0.1. - With an IPv4 literal that is not bound locally, the sort picks the numerically closest local address. For
10.244.1.9in the repro that is127.0.0.1. The Store README'sdocker runexample sets the host IP (hugegraph-store/README.md:363-364) on a bridge-network container, where that IP is not bound.
Fix direction
- In
getIpAddress(), skip loopback and link-local addresses (isLoopbackAddress(),isLinkLocalAddress()). - In
getNearestAddress(), return the configured address unchanged when the host is not a dotted IPv4 literal. Check this before the single-address shortcut at:72-74, instead of relying on theNumberFormatException. - Name the right method in the log message.
Vertex/Edge example (问题点 / 边数据举例)
Not applicable.
Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
Not applicable.
- 主要言語
- Java
- スター
- 3.2k
- フォーク
- 641
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 48
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/hugegraph のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
apache/hugegraph#3231 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug] Prometheus metrics format bug再び着手できるかも @cui2022 が 63 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
apache/hugegraph#3142 · コメント 7 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
メンテナーはふだん 1 日以内に返信
-
[Bug] CI accepts obsolete PR targets after retargeting or force-push再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
apache/hugegraph の issue をすべて見る
似ている issue
-
needs-area-label
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
quelea-projection/Quelea#711 ·
-
bug pdd
難易度 2/5 1時間未満 初心者へのやさしさ 67/100
objectionary/eo#9450 ·
メンテナーはふだん 1 日以内に返信
-
[EC2] DescribeAvailabilityZones should return real AWS error for unknown zone name対応中かも @omatheusmesmo が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
area: core good first issue type: enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100