bitflicker64 commented on code in PR #3330:
URL: https://github.com/apache/hugegraph/pull/3330#discussion_r4261509778
##########
hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/PartitionEngine.java:
##########
@@ -267,6 +271,23 @@ public LogStorage createLogStorage(final String uri, final
RaftOptions raftOptio
return this.started;
}
+ private void checkLegacyGraphIdData(int partitionId) {
+ Metapb.PartitionStore location =
+
this.partitionManager.getStoreMetadata().getPartitionStore(partitionId);
+ // Looking up or assigning a new store location would write metadata
before inspection.
+ String[] roots = location != null ? new
String[]{location.getStoreLocation()} :
+ this.storeEngine.getOption().getDataPath().split(",");
+ String dbName = BusinessHandlerImpl.getDbName(partitionId);
+ for (String root : roots) {
+ String dataPath = Paths.get(root,
HgStoreEngineOptions.DB_Path_Prefix).toString();
+ String existing = RocksDBSession.resolveExistingDBPath(
+ dataPath, dbName,
this.storeEngine.getCommittedIndex(partitionId));
+ if (existing != null) {
+ GraphIdManager.checkLegacyGraphIdData(existing, partitionId);
Review Comment:
Minor: on a normal start this is a third open of a database that was just
validated. `PartitionManager.loadPartitions` reads each partition through
`BusinessHandlerImpl.getSession`, so `createGraphDB` runs the validator on
every retained version and then opens the database read/write.
`PartitionMetaStoreWrapper.close` only releases a clone, so that session stays
in the factory cache. `restoreLocalPartitionEngine` then reaches `init`, which
resolves the same directory and opens it read-only once more while the
read/write session is still open. `restartRaftNode` repeats it on a live
database, and because `getSession` disables the WAL the read-only instance sees
flushed SST files only, not the memtable. Requested change: when
`RocksDBFactory.queryGraphDB(dbName)` returns a session, check it with the
existing `GraphIdManager.checkLegacyGraphIdData(RocksDBSession, int)` overload
and close the returned clone (or skip, as the factory does for cached
sessions), and keep the path-based che
ck for the case where nothing is open yet.
--
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]