Skip to content

Commit

Permalink
(feat) close the ‘fsync’ and ‘wal’ config of rheakv by default (#159)
Browse files Browse the repository at this point in the history
* (feat) close the ‘fsync’ and ‘wal’ config of rheakv by default #155

* (fix) fsync when compressSnapshot
  • Loading branch information
fengjiachun authored and killme2008 committed May 16, 2019
1 parent 69334e7 commit b76e3e6
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@
*/
public class RocksDBOptions {

private boolean sync = true;
// The raft log used fsync by default, and the correctness of
// state-machine data with rheakv depends on the raft log + snapshot,
// so we do not need to fsync.
private boolean sync = false;
// For the same reason(See the comment of ‘sync’ field), we also
// don't need WAL, which can improve performance.
private boolean disableWAL = true;
private boolean fastSnapshot = false;
private boolean openStatisticsCollector = true;
private long statisticsCallbackIntervalSeconds = 0;
Expand Down Expand Up @@ -53,6 +59,14 @@ public void setSync(boolean sync) {
this.sync = sync;
}

public boolean isDisableWAL() {
return disableWAL;
}

public void setDisableWAL(boolean disableWAL) {
this.disableWAL = disableWAL;
}

public boolean isFastSnapshot() {
return fastSnapshot;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ protected void compressSnapshot(final SnapshotWriter writer, final LocalFileMeta
final String writerPath = writer.getPath();
final String outputFile = Paths.get(writerPath, SNAPSHOT_ARCHIVE).toString();
try {
try (final ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outputFile))) {
ZipUtil.compressDirectoryToZipFile(writerPath, SNAPSHOT_DIR, out);
try (final FileOutputStream fOut = new FileOutputStream(outputFile);
final ZipOutputStream zOut = new ZipOutputStream(fOut)) {
ZipUtil.compressDirectoryToZipFile(writerPath, SNAPSHOT_DIR, zOut);
fOut.getFD().sync();
}
if (writer.addFile(SNAPSHOT_ARCHIVE, meta)) {
done.run(Status.OK());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public boolean init(final RocksDBOptions opts) {
this.cfDescriptors.add(new ColumnFamilyDescriptor(BytesUtil.writeUtf8("RHEA_FENCING"), cfOptions));
this.writeOptions = new WriteOptions();
this.writeOptions.setSync(opts.isSync());
this.writeOptions.setDisableWAL(false);
this.writeOptions.setDisableWAL(opts.isDisableWAL());
// Delete existing data, relying on raft's snapshot and log playback
// to reply to the data is the correct behavior.
destroyRocksDB(opts);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ placementDriverOptions:

storeEngineOptions:
rocksDBOptions:
sync: true
dbPath: rhea_db/
raftDataPath: rhea_raft/
serverAddress:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ placementDriverOptions:

storeEngineOptions:
rocksDBOptions:
sync: true
dbPath: rhea_db/
raftDataPath: rhea_raft/
serverAddress:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ placementDriverOptions:

storeEngineOptions:
rocksDBOptions:
sync: true
dbPath: rhea_db/
raftDataPath: rhea_raft/
serverAddress:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ placementDriverOptions:

storeEngineOptions:
rocksDBOptions:
sync: true
dbPath: rhea_db/
raftDataPath: rhea_raft/
serverAddress:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ placementDriverOptions:

storeEngineOptions:
rocksDBOptions:
sync: true
dbPath: rhea_db/
raftDataPath: rhea_raft/
serverAddress:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ placementDriverOptions:

storeEngineOptions:
rocksDBOptions:
sync: true
dbPath: rhea_pd_db/
raftDataPath: rhea_pd_raft/
serverAddress:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ placementDriverOptions:

storeEngineOptions:
rocksDBOptions:
sync: true
dbPath: rhea_pd_db/
raftDataPath: rhea_pd_raft/
serverAddress:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ placementDriverOptions:

storeEngineOptions:
rocksDBOptions:
sync: true
dbPath: rhea_pd_db/
raftDataPath: rhea_pd_raft/
serverAddress:
Expand Down
1 change: 0 additions & 1 deletion jraft-rheakv/rheakv-pd/src/test/resources/pd/pd_1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ rheaKVStoreOptions:

storeEngineOptions:
rocksDBOptions:
sync: true
dbPath: pd_db/
raftDataPath: pd_raft/
serverAddress:
Expand Down
1 change: 0 additions & 1 deletion jraft-rheakv/rheakv-pd/src/test/resources/pd/pd_2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ rheaKVStoreOptions:

storeEngineOptions:
rocksDBOptions:
sync: true
dbPath: pd_db/
raftDataPath: pd_raft/
serverAddress:
Expand Down
1 change: 0 additions & 1 deletion jraft-rheakv/rheakv-pd/src/test/resources/pd/pd_3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ rheaKVStoreOptions:

storeEngineOptions:
rocksDBOptions:
sync: true
dbPath: pd_db/
raftDataPath: pd_raft/
serverAddress:
Expand Down

0 comments on commit b76e3e6

Please sign in to comment.