incubator-hugegraph icon indicating copy to clipboard operation
incubator-hugegraph copied to clipboard

[Bug] usePD=true breaks on a JVM whose default locale uses a decimal comma (GraphSpace.info() formats "0,00")

Open SebastianGruza opened this issue 2 months ago • 0 comments

Bug Type (问题类型)

server status (启动/运行异常)

Before submit

  • [x] I have confirmed and searched that there are no similar problems in the historical issues and documents.

Environment (环境信息)

  • Server Version: master fabe0f0b (also seen on 98477f0 and on 1.7.0), tarball build
  • Backend: HStore (1 PD + 3 Store + 1 Server), usePD=true
  • OS: Debian 13, JDK 11, JVM started with -Duser.language=pl -Duser.country=PL (the same happens with de_DE, fr_FR, ru_RU, i.e. any default locale with a decimal comma)

Expected & Actual behavior (期望与实际表现)

Expected. A Server with usePD=true starts and serves graph spaces regardless of the JVM's default locale.

Actual. GraphSpace.info() (hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/space/GraphSpace.java:392-394) does

float storageUserPercent = Float.parseFloat(
        String.format("%.2f", (float) this.storageUsed / ((float) this.storageLimit * 1.0)));

String.format without a Locale follows the JVM default locale, so on pl_PL it yields "0,00", which Float.parseFloat rejects. info() runs whenever a GraphSpace is serialised (HugeGraphSONModule.GraphSpaceSerializer), so:

  • on a fresh PD the Server exits at startup in GraphManager.loadMetaFromPD() → createDefaultGraphSpaceIfNeeded():

    [ERROR] o.a.h.c.GraphManager - Unable to load meta for PD server and usePD = true in server options
    Exception in thread "main" java.lang.IllegalStateException: org.apache.hugegraph.HugeException: Can't write json: For input string: "0,00"
    Caused by: java.lang.NumberFormatException: For input string: "0,00"
    
  • on a PD that already holds a graph space the Server starts degraded: some graphs never load from meta (Failed to load graph '<g>' from meta server), DELETE /graphs/{g} fails (Can't find task scheduler for graph), and GET /graphspaces/{space} answers 400 Can't write json: For input string: "0,00".

Measured today on the lab: master fabe0f0b on a pl_PL JVM answers GET /graphspaces/DEFAULT with 400 {"exception":"class org.apache.hugegraph.HugeException","message":"Can't write json: For input string: \"0,00\"", ...}; with String.format(Locale.ROOT, ...) the same request answers 200 with the full space description. This is the only String.format("%.Nf") without a Locale in the server, PD and store main sources.

Workaround: LC_ALL=C.UTF-8 (or -Duser.language=en) for the Server JVM. Fix: format with Locale.ROOT; PR follows right away.

Vertex/Edge example (问题点 / 边数据举例)

No response

Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

No response

SebastianGruza avatar Sep 17 '26 13:09 SebastianGruza