LYD031106 commented on code in PR #2888:
URL:
https://github.com/apache/incubator-hugegraph/pull/2888#discussion_r2466062592
##########
hugegraph-server/hugegraph-mysql/src/main/java/org/apache/hugegraph/backend/store/mysql/MysqlStore.java:
##########
@@ -223,6 +223,7 @@ public void truncate() {
this.checkOpened();
this.truncateTables();
+ this.init();
Review Comment:
**Root Cause**
The issue stems from the fact that backend stores such as MySQL, HBase, and
RocksDB persist metadata (e.g., `driverVersion`) to the backend storage. When
the `truncate()` operation is executed to clear all table data, this metadata
is also deleted. As a result, subsequent operations fail due to missing
metadata or state conflicts.
**Analysis by Backend**
- **RocksDB**:
Although affected by the same problem, its `truncate()` method explicitly
calls `this.init()` after clearing data to reinitialize the metadata, thereby
avoiding errors.
```
@Override
public synchronized void truncate() {
Lock writeLock = this.storeLock.writeLock();
writeLock.lock();
try {
this.checkOpened();
this.clear(false);
this.init();
// Clear write-batch
this.dbs.values().forEach(BackendSessionPool::forceResetSessions);
LOG.debug("Store truncated: {}", this.store);
} finally {
writeLock.unlock();
}
}
```
- **HBase**:
Confirmed to have the same issue as MySQL.
Action Required: A follow-up PR is needed to fix the HBase backend
accordingly.
- **Memory / HStore**:
These backends are not affected because they do not persist critical
version information or similar metadata to the backend storage.
--
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]