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

[SPARK-49677][SS] Ensure that changelog files are written on commit and forceSnapshot flag is also reset #48125

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -646,15 +646,15 @@ class RocksDB(
// is enabled.
if (shouldForceSnapshot.get()) {
uploadSnapshot()
shouldForceSnapshot.set(false)
}

// ensure that changelog files are always written
try {
assert(changelogWriter.isDefined)
changelogWriter.foreach(_.commit())
} finally {
changelogWriter = None
changelogWriter.foreach(_.abort())
} else {
try {
assert(changelogWriter.isDefined)
changelogWriter.foreach(_.commit())
} finally {
changelogWriter = None
}
}
} else {
assert(changelogWriter.isEmpty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,47 @@ class RocksDBSuite extends AlsoTestWithChangelogCheckpointingEnabled with Shared
}
}

testWithChangelogCheckpointingEnabled("RocksDB: ensure that changelog files are written " +
"and snapshots uploaded optionally with changelog format v2") {
withTempDir { dir =>
val remoteDir = Utils.createTempDir().toString
val conf = dbConf.copy(minDeltasForSnapshot = 5, compactOnCommit = false)
new File(remoteDir).delete() // to make sure that the directory gets created
withDB(remoteDir, conf = conf, useColumnFamilies = true) { db =>
db.createColFamilyIfAbsent("test")
db.load(0)
db.put("a", "1")
db.put("b", "2")
db.commit()
assert(changelogVersionsPresent(remoteDir) == Seq(1))
assert(snapshotVersionsPresent(remoteDir) == Seq(1))

db.load(1)
db.put("a", "3")
db.put("c", "4")
db.commit()

assert(changelogVersionsPresent(remoteDir) == Seq(1, 2))
assert(snapshotVersionsPresent(remoteDir) == Seq(1))

db.removeColFamilyIfExists("test")
db.load(2)
db.remove("a")
db.put("d", "5")
db.commit()
assert(changelogVersionsPresent(remoteDir) == Seq(1, 2, 3))
assert(snapshotVersionsPresent(remoteDir) == Seq(1, 3))

db.load(3)
db.put("e", "6")
db.remove("b")
db.commit()
assert(changelogVersionsPresent(remoteDir) == Seq(1, 2, 3, 4))
assert(snapshotVersionsPresent(remoteDir) == Seq(1, 3))
}
}
}

test("RocksDB: ensure merge operation correctness") {
withTempDir { dir =>
val remoteDir = Utils.createTempDir().toString
Expand Down