LYD031106 commented on issue #2209:
URL: 
https://github.com/apache/incubator-hugegraph/issues/2209#issuecomment-3410891988

   Hello everyone,
   
   I've conducted a preliminary analysis on Issue [#2209 The backend store 
version is 
inconsistent](https://github.com/apache/incubator-hugegraph/issues/2209), 
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`](https://github.com/apache/incubator-hugegraph/blob/master/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!


-- 
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]

Reply via email to