You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/07/05 14:58:23 UTC
[GitHub] [ignite-3] rpuch commented on a diff in pull request #924: IGNITE-17303 RocksDB snapshots might include writes added after snapshot creation start
rpuch commented on code in PR #924:
URL: https://github.com/apache/ignite-3/pull/924#discussion_r913898510
##########
modules/rocksdb-common/src/main/java/org/apache/ignite/internal/rocksdb/snapshot/RocksSnapshotManager.java:
##########
@@ -77,18 +78,22 @@ public RocksSnapshotManager(RocksDB db, Collection<ColumnFamilyRange> ranges, Ex
public CompletableFuture<Void> createSnapshot(Path snapshotDir) {
Path tmpPath = Paths.get(snapshotDir.toString() + TMP_SUFFIX);
- return CompletableFuture.supplyAsync(db::getSnapshot, executor)
- .thenComposeAsync(snapshot -> {
+ // The snapshot reference must be taken synchronously, otherwise we might let more writes sneak into the snapshot than needed.
+ Snapshot snapshot = db.getSnapshot();
+
+ return CompletableFuture.supplyAsync(
+ () -> {
createTmpSnapshotDir(tmpPath);
// Create futures for capturing SST snapshots of the column families
CompletableFuture<?>[] sstFutures = ranges.stream()
.map(cf -> createSstFileAsync(cf, snapshot, tmpPath))
.toArray(CompletableFuture[]::new);
- return CompletableFuture.allOf(sstFutures).thenApply(v -> snapshot);
+ return CompletableFuture.allOf(sstFutures);
}, executor)
- .whenCompleteAsync((snapshot, e) -> {
+ .thenCompose(Function.identity())
+ .whenCompleteAsync((ignored, e) -> {
if (e != null) {
Review Comment:
Thanks for catching this
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org