Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
Change-Id: Ia6493b81a96f87b7ff1f7a7b365281f99b528111
  • Loading branch information
zhoney committed Jul 2, 2021
1 parent 87259c1 commit f4a5a66
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ public void truncateBackend() {
this.storeProvider.initSystemInfo(this);
this.serverStarted(this.serverInfoManager().selfServerId(),
this.serverInfoManager().selfServerRole());
this.createSnapshotIfNeeded();
} finally {
LockUtil.unlock(this.name, LockUtil.GRAPH_LOCK);
}
Expand Down Expand Up @@ -498,23 +497,6 @@ private Analyzer analyzer() {
return AnalyzerFactory.analyzer(name, mode);
}

private void createSnapshotIfNeeded() {
if (!this.storeProvider.type().equals("rocksdb")) {
return;
}
/*
* Take the initiative to generate a snapshot, it can avoid this
* situation: when the server restart need to read the database
* (such as checkBackendVersionInfo), it happens that raft replays
* the truncate log, at the same time, the store has been cleared
* (truncate) but init-store has not been completed, which will
* cause reading errors.
* When restarting, load the snapshot first and then read backend,
* will not encounter such an intermediate state.
*/
this.storeProvider.createSnapshot();
}

protected void reloadRamtable() {
this.reloadRamtable(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,18 @@ public void initSystemInfo(HugeGraph graph) {

this.notifyAndWaitEvent(Events.STORE_INITED);
LOG.debug("Graph '{}' system info has been initialized", this.graph());
/*
* Take the initiative to generate a snapshot, it can avoid this
* situation: when the server restart need to read the database
* (such as checkBackendVersionInfo), it happens that raft replays
* the truncate log, at the same time, the store has been cleared
* (truncate) but init-store has not been completed, which will
* cause reading errors.
* When restarting, load the snapshot first and then read backend,
* will not encounter such an intermediate state.
*/
this.createSnapshot();
LOG.debug("Graph '{}' snapshot has been created", this.graph());
}

@Override
Expand Down

0 comments on commit f4a5a66

Please sign in to comment.