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

[Bug] The backend store version is inconsistent

Open lanerbean opened this issue 3 years ago • 17 comments

Bug Type (问题类型)

server status (启动/运行异常)

Before submit

  • [X] 我已经确认现有的 Issues 与 FAQ 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)

Environment (环境信息)

  • Server Version: 1.0.0 (Apache Release Version)
  • Backend: MySQL
  • OS: CentOS 7.x

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

When the HugeGraph Server and Hadoop cluster are shut down and restarted, an error is encountered, causing the startup to fail. error1

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

No response

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

No response

lanerbean avatar May 13 '23 09:05 lanerbean

U could add & print the log (what's the differ version) and how to reproduce it?

imbajin avatar May 14 '23 12:05 imbajin

问一下楼主是怎么解决的,我这边也是同样的问题。

lp19910807 avatar May 22 '23 07:05 lp19910807

U could add & print the log (what's the differ version) and how to reproduce it?

您好,我是在3台虚拟机上部署的Hadoop集群,并在其中一台机器上部署了HugeGraph,每次关闭HugeGraph,Hadoop集群,并且关闭虚拟机之后,第二天重启Hadoop集群,再开启HugeGraph Server时,就会出现图数据版本不一致的问题。

我之前采用的解决方法非常暴力,直接删除了MySQL(后台图数据库)的hugegraph,然后在MySQL重新创建了hugegraph数据库,重新init和启动了HugeGraph Server。

这种方法,会导致之前导入的图数据都会丢失,需要重新导入,很不方便。不知道该如何回避这种问题的出现。

lanerbean avatar May 30 '23 09:05 lanerbean

U could add & print the log (what's the differ version) and how to reproduce it?

您好,我是在3台虚拟机上部署的Hadoop集群,并在其中一台机器上部署了HugeGraph,每次关闭HugeGraph,Hadoop集群,并且关闭虚拟机之后,第二天重启Hadoop集群,再开启HugeGraph Server时,就会出现图数据版本不一致的问题。

我之前采用的解决方法非常暴力,直接删除了MySQL(后台图数据库)的hugegraph,然后在MySQL重新创建了hugegraph数据库,重新init和启动了HugeGraph Server。

这种方法,会导致之前导入的图数据都会丢失,需要重新导入,很不方便。不知道该如何回避这种问题的出现。

我理解 hadoop 环境在这里应该和图是基本没有关系的吧, mysql 来说, 一台单独的虚拟机甚至是容器环境应该也都足矣了, 能否保持一个 clean 的环境试试呢? 或者你甚至可以在 server 的 docker 镜像中配置一下 mysql, 然后看看是否会有类似问题

imbajin avatar May 30 '23 09:05 imbajin

是不是因为HugeGraph和MySQL不在同一台机器上导致的呢?并且MySQL也是部署在虚拟机上的,应该也是关闭过服务又重启的

lanerbean avatar May 30 '23 09:05 lanerbean

是不是因为HugeGraph和MySQL不在同一台机器上导致的呢?并且MySQL也是部署在虚拟机上的,应该也是关闭过服务又重启的

虚拟机不会是影响点, 关键的问题应该是其他环境或者状态的变化, 最简单好排除的办法就是在容器里进行测试(获得一个 clean 的环境), 看是否还有同样的问题, 包括你在容器里可以把 mysql 也内嵌进去/或者是单独另一个容器关联都行.

imbajin avatar May 30 '23 09:05 imbajin

存储store的m 库没有数据导致,添加下name version,value 提示的版本号就可以,问题是BackendStore代码逻辑里写了insert 为啥没有执行呢?

robinhood-jim avatar Dec 14 '23 08:12 robinhood-jim

MysqlSystemStore 的init方法调用this.meta.writeVersion 应该将versin写入m表,问题是不管InitStore还是第一次启动,在mysql作为存储的情况下m表都是空的,导致下次启动时检查版本报错,我本地已重现两次,麻烦定位下问题点

robinhood-jim avatar Dec 15 '23 03:12 robinhood-jim

MysqlSystemStore 的init方法调用this.meta.writeVersion 应该将versin写入m表,问题是不管InitStore还是第一次启动,在mysql作为存储的情况下m表都是空的,导致下次启动时检查版本报错,我本地已重现两次,麻烦定位下问题点

@z7658329 could u take a look for it?

imbajin avatar Dec 15 '23 03:12 imbajin

In the latest version, the same error occurred when using Cassandra as the backend

2025-01-02 09:24:43 [main] [INFO] o.a.h.c.GraphManager - Graph 'hugegraph3' was successfully configured via './conf/graphs/hugegraph3.properties'
2025-01-02 09:24:43 [main] [INFO] o.a.h.b.c.CacheManager - Init RamCache for 'schema-id-hugegraph1' with capacity 10000
2025-01-02 09:24:43 [main] [INFO] o.a.h.b.c.CacheManager - Init RamCache for 'schema-name-hugegraph1' with capacity 10000
2025-01-02 09:24:43 [main] [INFO] o.a.h.b.c.CacheManager - Init LevelCache for 'vertex-hugegraph1' with capacity 10000:10000000
2025-01-02 09:24:43 [main] [INFO] o.a.h.b.c.CacheManager - Init LevelCache for 'edge-hugegraph1' with capacity 1000:1000000
2025-01-02 09:24:43 [main] [INFO] o.a.h.t.TaskManager - Use local as the scheduler of graph (hugegraph1)
2025-01-02 09:24:43 [main] [INFO] o.a.h.b.c.CacheManager - Init RamCache for 'users-hugegraph1' with capacity 10240
2025-01-02 09:24:43 [main] [INFO] o.a.h.b.c.CacheManager - Init RamCache for 'users_pwd-hugegraph1' with capacity 10240
2025-01-02 09:24:43 [main] [INFO] o.a.h.b.c.CacheManager - Init RamCache for 'token-hugegraph1' with capacity 10240
2025-01-02 09:24:43 [main] [INFO] o.a.h.c.GraphManager - Graph 'hugegraph1' was successfully configured via './conf/graphs/hugegraph1.properties'
2025-01-02 09:24:43 [main] [WARN] o.a.h.c.GraphManager - You may need to support access control for './conf/graphs/hugegraph1.properties' with gremlin.graph=org.apache.hugegraph.auth.HugeFactoryAuthProxy
2025-01-02 09:24:43 [main] [INFO] o.a.h.b.c.CacheManager - Init RamCache for 'schema-id-kgk1' with capacity 10000
2025-01-02 09:24:43 [main] [INFO] o.a.h.b.c.CacheManager - Init RamCache for 'schema-name-kgk1' with capacity 10000
2025-01-02 09:24:43 [main] [INFO] o.a.h.b.c.CacheManager - Init LevelCache for 'vertex-kgk1' with capacity 10000:10000000
2025-01-02 09:24:43 [main] [INFO] o.a.h.b.c.CacheManager - Init LevelCache for 'edge-kgk1' with capacity 1000:1000000
2025-01-02 09:24:43 [main] [INFO] o.a.h.t.TaskManager - Use local as the scheduler of graph (kgk1)
2025-01-02 09:24:43 [main] [INFO] o.a.h.b.c.CacheManager - Init RamCache for 'users-kgk1' with capacity 10240
2025-01-02 09:24:43 [main] [INFO] o.a.h.b.c.CacheManager - Init RamCache for 'users_pwd-kgk1' with capacity 10240
2025-01-02 09:24:43 [main] [INFO] o.a.h.b.c.CacheManager - Init RamCache for 'token-kgk1' with capacity 10240
2025-01-02 09:24:43 [main] [INFO] o.a.h.b.c.CacheManager - Init RamCache for 'audit-log-limiter-kgk1' with capacity 10240
2025-01-02 09:24:43 [main] [INFO] o.a.h.b.c.CacheManager - Init RamCache for 'users-role-kgk1' with capacity 10240
2025-01-02 09:24:43 [main] [INFO] o.a.h.c.GraphManager - Graph 'kgk1' was successfully configured via './conf/graphs/kgk1.properties'
2025-01-02 09:24:43 [main] [INFO] o.a.h.c.GraphManager - RpcServer is not enabled, skip starting rpc service
2025-01-02 09:24:43 [main] [INFO] o.a.h.c.GraphManager - RpcServer is not enabled, skip wait graphs ready
2025-01-02 09:24:43 [main] [INFO] o.a.h.c.GraphManager - Check backend version
2025-01-02 09:24:43 [main] [ERROR] o.a.h.b.s.BackendStoreInfo - The backend driver version '1.11' is inconsistent with the data version 'null' of backend store for graph 'kgkg111'
2025-01-02 09:24:43 [main] [INFO] o.a.h.StandardHugeGraph - Close graph standardhugegraph[dzbtest]
2025-01-02 09:24:49 [main] [INFO] o.a.h.StandardHugeGraph - Close graph standardhugegraph[kgkg111]
2025-01-02 09:24:55 [main] [INFO] o.a.h.StandardHugeGraph - Close graph standardhugegraph[hugegraph1]
2025-01-02 09:25:01 [main] [INFO] o.a.h.StandardHugeGraph - Close graph standardhugegraph[hugegraph2]
2025-01-02 09:25:07 [main] [INFO] o.a.h.StandardHugeGraph - Close graph standardhugegraph[kgk1]
2025-01-02 09:25:13 [main] [INFO] o.a.h.StandardHugeGraph - Close graph standardhugegraph[hugegraph]
2025-01-02 09:25:19 [main] [INFO] o.a.h.StandardHugeGraph - Close graph standardhugegraph[test_kb_1]
2025-01-02 09:25:25 [main] [INFO] o.a.h.StandardHugeGraph - Close graph standardhugegraph[hugegraph3]
2025-01-02 09:25:31 [main] [INFO] o.a.h.StandardHugeGraph - Close graph standardhugegraph[hugegraph4]
2025-01-02 09:25:37 [main] [INFO] o.a.h.StandardHugeGraph - Close graph standardhugegraph[huge02]
2025-01-02 09:25:43 [main] [INFO] o.a.h.StandardHugeGraph - Close graph standardhugegraph[huge01]
2025-01-02 09:25:49 [main] [INFO] o.a.h.StandardHugeGraph - Close graph standardhugegraph[huge03]
2025-01-02 09:25:56 [main] [ERROR] o.a.h.d.HugeGraphServer - HugeRestServer start error: 
org.apache.hugegraph.backend.BackendException: The backend store version is inconsistent
	at org.apache.hugegraph.core.GraphManager.checkBackendVersionOrExit(GraphManager.java:456) ~[hugegraph-api-1.5.0.jar:0.71.0.0]
	at org.apache.hugegraph.core.GraphManager.init(GraphManager.java:124) ~[hugegraph-api-1.5.0.jar:0.71.0.0]
	at org.apache.hugegraph.server.ApplicationConfig$GraphManagerFactory$1.onEvent(ApplicationConfig.java:143) ~[hugegraph-api-1.5.0.jar:0.71.0.0]
	at org.glassfish.jersey.server.internal.monitoring.CompositeApplicationEventListener.onEvent(CompositeApplicationEventListener.java:49) ~[jersey-server-3.0.3.jar:?]
	at org.glassfish.jersey.server.internal.monitoring.MonitoringContainerListener.onStartup(MonitoringContainerListener.java:56) ~[jersey-server-3.0.3.jar:?]
	at org.glassfish.jersey.server.ApplicationHandler.onStartup(ApplicationHandler.java:711) ~[jersey-server-3.0.3.jar:?]
	at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.start(GrizzlyHttpContainer.java:330) ~[jersey-container-grizzly2-http-3.0.3.jar:?]
	at org.glassfish.grizzly.http.server.HttpHandlerChain.start(HttpHandlerChain.java:376) ~[grizzly-http-server-3.0.1.jar:3.0.1]
	at org.glassfish.grizzly.http.server.HttpServer.setupHttpHandler(HttpServer.java:268) ~[grizzly-http-server-3.0.1.jar:3.0.1]
	at org.glassfish.grizzly.http.server.HttpServer.start(HttpServer.java:245) ~[grizzly-http-server-3.0.1.jar:3.0.1]
	at org.apache.hugegraph.server.RestServer.start(RestServer.java:70) ~[hugegraph-api-1.5.0.jar:0.71.0.0]
	at org.apache.hugegraph.server.RestServer.start(RestServer.java:177) ~[hugegraph-api-1.5.0.jar:0.71.0.0]
	at org.apache.hugegraph.dist.HugeRestServer.start(HugeRestServer.java:31) ~[hugegraph-dist-1.5.0.jar:1.5.0]
	at org.apache.hugegraph.dist.HugeGraphServer.<init>(HugeGraphServer.java:61) ~[hugegraph-dist-1.5.0.jar:1.5.0]
	at org.apache.hugegraph.dist.HugeGraphServer.main(HugeGraphServer.java:127) ~[hugegraph-dist-1.5.0.jar:1.5.0]
2025-01-02 09:25:56 [main] [INFO] o.a.h.HugeFactory - HugeFactory shutdown
2025-01-02 09:25:56 [hugegraph-shutdown] [INFO] o.a.h.HugeFactory - HugeGraph is shutting down
java:711)
	at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.start(GrizzlyHttpContainer.java:330)
	at org.glassfish.grizzly.http.server.HttpHandlerChain.start(HttpHandlerChain.java:376)
	at org.glassfish.grizzly.http.server.HttpServer.setupHttpHandler(HttpServer.java:268)
	at org.glassfish.grizzly.http.server.HttpServer.start(HttpServer.java:245)
	at org.apache.hugegraph.server.RestServer.start(RestServer.java:70)
	at org.apache.hugegraph.server.RestServer.start(RestServer.java:177)
	at org.apache.hugegraph.dist.HugeRestServer.start(HugeRestServer.java:31)
	at org.apache.hugegraph.dist.HugeGraphServer.<init>(HugeGraphServer.java:61)
	at org.apache.hugegraph.dist.HugeGraphServer.main(HugeGraphServer.java:127)

ieayoio avatar Jan 02 '25 10:01 ieayoio

@imbajin

I've conducted a preliminary analysis on Issue #2209 The backend store version is inconsistent, specifically focusing on the behavior when MySQL is used as the backend store.

🐞 Problem Analysis

  1. Key File: The core logic resides in hugegraph-server/hugegraph-mysql/src/main/java/org/apache/hugegraph/backend/store/mysql/MysqlTables.java.
  2. Symptom: During server startup (including restarts and normal operations), the version check fails because the metadata table for version information (the m table in MySQL) is empty, even though the overall database (Store) exists.
  3. Root Cause (Detailed):
  • When the server starts, the version check logic calls readVersion(). Since the m table is empty, readVersion() returns null, leading to a version inconsistency error.
  • The primary mechanism for writing the version, writeVersion(), is located within the initStore() method.
  • During a non-initial startup, if backendStoreInfo. exists() returns true (indicating the database is present), initStore() skips the complete database re-initialization (which would include calling writeVersion()).
  • Consequently, the empty m table is not updated, the version check fails, and the initialization process terminates.

💡 Proposed Solution

My initial proposal is to ensure that writeVersion is called unconditionally within the initStore process, provided the database exists.

This would guarantee that the version number is correctly written or updated to the backend store's metadata table, regardless of whether the database is being initialized for the first time or is simply being re-opened after a restart.

I hope we can have a further discussion on this analysis and proposed fix to confirm the optimal approach, and I am ready to participate in implementing the solution.

Looking forward to your feedback!

LYD031106 avatar Oct 16 '25 13:10 LYD031106

I'd like to take this issue. Could you please assign it to me?

LYD031106 avatar Oct 19 '25 15:10 LYD031106

@imbajin

I've conducted a preliminary analysis on Issue #2209 The backend store version is inconsistent, specifically focusing on the behavior when MySQL is used as the backend store.

🐞 Problem Analysis

  1. Key File: The core logic resides in hugegraph-server/hugegraph-mysql/src/main/java/org/apache/hugegraph/backend/store/mysql/MysqlTables.java.
  2. Symptom: During server startup (including restarts and normal operations), the version check fails because the metadata table for version information (the m table in MySQL) is empty, even though the overall database (Store) exists.
  3. Root Cause (Detailed):
  • When the server starts, the version check logic calls readVersion(). Since the m table is empty, readVersion() returns null, leading to a version inconsistency error.
  • The primary mechanism for writing the version, writeVersion(), is located within the initStore() method.
  • During a non-initial startup, if backendStoreInfo. exists() returns true (indicating the database is present), initStore() skips the complete database re-initialization (which would include calling writeVersion()).
  • Consequently, the empty m table is not updated, the version check fails, and the initialization process terminates.

💡 Proposed Solution

My initial proposal is to ensure that writeVersion is called unconditionally within the initStore process, provided the database exists.

This would guarantee that the version number is correctly written or updated to the backend store's metadata table, regardless of whether the database is being initialized for the first time or is simply being re-opened after a restart.

I hope we can have a further discussion on this analysis and proposed fix to confirm the optimal approach, and I am ready to participate in implementing the solution.

Looking forward to your feedback!

@LYD031106 (Miss the message) Thanks for your detailed explanation, nice to see your contribution~

imbajin avatar Oct 20 '25 09:10 imbajin

@imbajin ## Problem Analysis

During testing of the incubator-hugegraph-toolchain dataloader component, it was discovered that the /graphs/{name}/clear interface called in the setUp method clears all data tables, including the m table that stores version information. This is the root cause of the current bug.

Proposed Solutions

Solution 1: Add compatibility handling for empty tables in the InitStore method. When it is detected that the version information table is empty, automatically write the current version number and return normally, thereby allowing the system initialization to complete successfully even after the data has been cleared.

Solution 2: Modify the MysqlStore.truncateTables() method so that after clearing all data tables, the init method is called again to rewrite the necessary version information, ensuring the version table remains in a valid state at all times.

Do you have any suggestions regarding these two solutions? Personally, I lean towards Solution 2, as it addresses the issue at its source and more thoroughly ensures data state consistency

LYD031106 avatar Oct 21 '25 09:10 LYD031106

@imbajin ## Problem Analysis

During testing of the incubator-hugegraph-toolchain dataloader component, it was discovered that the /graphs/{name}/clear interface called in the setUp method clears all data tables, including the m table that stores version information. This is the root cause of the current bug.

Proposed Solutions

Solution 1: Add compatibility handling for empty tables in the InitStore method. When it is detected that the version information table is empty, automatically write the current version number and return normally, thereby allowing the system initialization to complete successfully even after the data has been cleared.

Solution 2: Modify the MysqlStore.truncateTables() method so that after clearing all data tables, the init method is called again to rewrite the necessary version information, ensuring the version table remains in a valid state at all times.

Do you have any suggestions regarding these two solutions? Personally, I lean towards Solution 2, as it addresses the issue at its source and more thoroughly ensures data state consistency

@LYD031106 Solution2 is fine to me in this case, and we could add basic tests for it to reproduce it & ensure the correctness

BTW, in the future version we’ll use PD to manage the meta-info, and MySQL backend will only keep in the legacy version

imbajin avatar Oct 21 '25 09:10 imbajin

Allright, I think this could fix the bug in this release

LYD031106 avatar Oct 21 '25 11:10 LYD031106

Allright, I think this could fix the bug in this release

@LYD031106 we'll prepare to release the new version 1.7.0 this week(u could submit the PR ASAP~)

imbajin avatar Oct 21 '25 13:10 imbajin