Skip to content
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

Let snapshot saved disk same as rocksdb data path #1392

Merged
merged 13 commits into from
Apr 1, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ public class HugeSecurityManager extends SecurityManager {
);

private static final Map<String, Set<String>> ROCKSDB_SNAPSHOT = ImmutableMap.of(
Linary marked this conversation as resolved.
Show resolved Hide resolved
"com.baidu.hugegraph.backend.store.rocksdb.RocksDBStore",
"com.baidu.hugegraph.backend.store.AbstractBackendStoreProvider",
Linary marked this conversation as resolved.
Show resolved Hide resolved
ImmutableSet.of("createSnapshot", "resumeSnapshot"),
"com.baidu.hugegraph.backend.store.raft.RaftBackendStoreProvider",
ImmutableSet.of("createSnapshot", "resumeSnapshot")
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public void resumeSnapshot(String snapshotPath) {

@Override
public String buildSnapshotPath(String snapshotPrefix) {
// Like: parent_path/rocksdb-data/*, * maybe g,m,s
// Like: parent_path/rocksdb-data/*, * can be g,m,s
Path originDataPath = Paths.get(this.dataPath);
Path parentParentPath = originDataPath.getParent().getParent();
// Like: rocksdb-data/*
Expand All @@ -306,7 +306,8 @@ public String hardLinkSnapshot(String snapshotPath) throws RocksDBException {
snapshotPath, null).rocksdb) {
RocksDBStdSessions.createCheckpoint(rocksdb, snapshotLinkPath);
}
LOG.debug("The snapshot data link path: {}", snapshotLinkPath);
LOG.debug("The snapshot {} has been hard linked to {}",
snapshotPath, snapshotLinkPath);
return snapshotLinkPath;
}

Expand Down Expand Up @@ -438,6 +439,8 @@ private static Set<String> mergeOldCFs(String path, List<String> cfNames)
}

private static void createCheckpoint(RocksDB rocksdb, String targetPath) {
Linary marked this conversation as resolved.
Show resolved Hide resolved
Path parentPath = Paths.get(targetPath).getParent().getFileName();
assert parentPath.startsWith("snapshot") : targetPath;
// https://github.com/facebook/rocksdb/wiki/Checkpoints
try (Checkpoint checkpoint = Checkpoint.create(rocksdb)) {
String tempPath = targetPath + "_temp";
Expand Down Expand Up @@ -1219,7 +1222,7 @@ private boolean filter(byte[] key) {
*/
assert this.keyEnd != null;
if (this.match(Session.SCAN_LTE_END)) {
// Just compare the prefix, maybe there are excess tail
// Just compare the prefix, can be there are excess tail
key = Arrays.copyOfRange(key, 0, this.keyEnd.length);
return Bytes.compare(key, this.keyEnd) <= 0;
} else {
Expand Down