-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement raft snapshot mechanism by rocksdb checkpoint #1247
Conversation
f027175
to
8405036
Compare
@@ -129,6 +129,7 @@ public void open(String name) { | |||
@Override | |||
public void waitStoreStarted() { | |||
this.context.initRaftNode(); | |||
LOG.info("The raft node was inited"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The raft node is initialized
} | ||
LOG.info("The store {} load snapshot succeed", this.store); | ||
} catch (RocksDBException e) { | ||
throw new BackendException("Failed to reload rocksdb: " + e.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use %s
@@ -586,21 +581,22 @@ protected Session session(HugeType tableType) { | |||
|
|||
@Override | |||
public void writeSnapshot(String parentPath) { | |||
Lock readLock = this.truncateLock.readLock(); | |||
readLock.lock(); | |||
Lock writeLock = this.truncateLock.writeLock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to storeLock
* it may produce dirty data. | ||
*/ | ||
for (RocksDBSessions sessions : this.dbs.values()) { | ||
if (sessions instanceof RocksDBStdSessions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move forceCloseRocksDB to RocksDBSessions
for (RocksDBSessions sessions : this.dbs.values()) { | ||
sessions.reload(); | ||
} | ||
LOG.info("The store {} load snapshot succeed", this.store); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
successfully
executor.execute(() -> compressSnapshot(writer, metaBuilder, | ||
done)); | ||
} else { | ||
LOG.error("Failed to save snapshot, path={}, files={}, {}.", | ||
writerPath, writer.listFiles(), throwable); | ||
writerPath, writer.listFiles(), t); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Failed to save snapshot, path={}, files={}", the exception stack will be printed
return CompletableFuture.completedFuture(LocalFileMeta.newBuilder()); | ||
} | ||
|
||
public void doSnapshotLoad(BackendStore store, String snapshotPath) { | ||
store.readSnapshot(snapshotPath); | ||
public void doSnapshotLoad(String snapshotPath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set private
@@ -186,6 +186,10 @@ public StoreType storeType(String store) { | |||
} | |||
} | |||
|
|||
public RaftBackendStore[] stores() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set protected
@@ -64,7 +64,8 @@ public void save(SnapshotWriter writer, Closure done, | |||
executor.execute(() -> compressSnapshot(writer, metaBuilder, | |||
done)); | |||
} else { | |||
LOG.error("Failed to save snapshot, path={}, files={}, {}.", | |||
LOG.error("Failed to save snapshot, path={}, files={}, " + | |||
"the exception stack will be printed.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"the exception stack will be printed" is just comment
@@ -129,8 +129,9 @@ public void open(String name) { | |||
@Override | |||
public void waitStoreStarted() { | |||
this.context.initRaftNode(); | |||
LOG.info("The raft node is initialized"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove "is"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer keep it
this.context.waitRaftNodeStarted(); | ||
LOG.info("The raft store was started"); | ||
LOG.info("The raft store is started"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove "is"
Change-Id: I761c01da871aac6fe6e906f6150c66c7f5b8f67b
Change-Id: Ia423824791a1c6bd611e981facaf7a26c94fc5ca
Change-Id: Ib2c72eab8b91abbba55cca3b309ed91e35654083
Change-Id: I27be0ad4bf78694e98855d77450a97f447832114
Change-Id: I157a1c3b6f893083f507b99a22e717e2b89eb2ce
Change-Id: I205329c07fc8bac0f9731e77ddc842f1366d21ec
Change-Id: I37779caec0fdd50276f8597fa4540df39ad40942
public void reload() throws RocksDBException { | ||
if (this.rocksdb.isOwningHandle()) { | ||
this.rocksdb.close(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move line 259 to line 256
@@ -265,7 +260,7 @@ protected RocksDBSessions open(HugeConfig config, String dataPath, | |||
sessions = this.openSessionPool(config, dataPath, | |||
walPath, tableNames); | |||
} catch (RocksDBException e) { | |||
RocksDBSessions origin = dbs.get(dataPath); | |||
RocksDBSessions origin = this.dbs.get(dataPath); | |||
if (origin != null) { | |||
if (e.getMessage().contains("No locks available")) { | |||
// Open twice, but we should support keyspace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update comments:
Open twice, copy a RocksDBSessions reference, since from v0.11.2 release we don't support multi graphs share rocksdb instance (before v0.11.2 graphs with different CF-prefix share one rocksdb instance and data path), so each graph has its independent data paths, but multi CFs may share same optimized disk(or optimized disk path).
Change-Id: I5faf30bc530a6ad21fee81fef22614d4e46123a9
a6aac8f
Codecov Report
@@ Coverage Diff @@
## master #1247 +/- ##
============================================
- Coverage 69.19% 62.38% -6.81%
- Complexity 5401 5766 +365
============================================
Files 328 374 +46
Lines 26334 31329 +4995
Branches 3750 4398 +648
============================================
+ Hits 18222 19545 +1323
- Misses 6333 9800 +3467
- Partials 1779 1984 +205
Continue to review full report at Codecov.
|
* adapt with dbs as member field * Adapt MultiGraphTests Change-Id: I5faf30bc530a6ad21fee81fef22614d4e46123a9
Change-Id: I761c01da871aac6fe6e906f6150c66c7f5b8f67b