Skip to content

Commit

Permalink
fix clear api create snapshot for all backend(should rocksdb only)
Browse files Browse the repository at this point in the history
Change-Id: I936ee13a0a4f8afc61384fe6adee89bbb74c8256
  • Loading branch information
zhoney committed Jul 1, 2021
1 parent 23beacd commit 87259c1
Showing 1 changed file with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,17 +362,7 @@ public void truncateBackend() {
this.storeProvider.initSystemInfo(this);
this.serverStarted(this.serverInfoManager().selfServerId(),
this.serverInfoManager().selfServerRole());
/*
* 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();
this.createSnapshotIfNeeded();
} finally {
LockUtil.unlock(this.name, LockUtil.GRAPH_LOCK);
}
Expand Down Expand Up @@ -508,6 +498,23 @@ 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

0 comments on commit 87259c1

Please sign in to comment.