Skip to content

[SPARK-51972][SS] State Store file integrity verification using checksum #50773

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions common/utils/src/main/resources/error/error-conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,13 @@
],
"sqlState" : "42P08"
},
"CHECKPOINT_FILE_CHECKSUM_VERIFICATION_FAILED" : {
"message" : [
"Checksum verification failed, the file may be corrupted. File: <fileName>",
"Expected (file size: <expectedSize>, checksum: <expectedChecksum>), Computed (file size: <computedSize>, checksum: <computedChecksum>)."
],
"sqlState" : "XX000"
},
"CHECKPOINT_RDD_BLOCK_ID_NOT_FOUND" : {
"message" : [
"Checkpoint block <rddBlockId> not found!",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ private[spark] object LogKeys {
case object CHECKPOINT_PATH extends LogKey
case object CHECKPOINT_ROOT extends LogKey
case object CHECKPOINT_TIME extends LogKey
case object CHECKSUM extends LogKey
case object CHOSEN_WATERMARK extends LogKey
case object CLASSIFIER extends LogKey
case object CLASS_LOADER extends LogKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2622,6 +2622,23 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase with ExecutionE
cause = null)
}

def checkpointFileChecksumVerificationFailed(
file: Path,
expectedSize: Long,
expectedChecksum: Int,
computedSize: Long,
computedChecksum: Int): Throwable = {
new SparkException(
errorClass = "CHECKPOINT_FILE_CHECKSUM_VERIFICATION_FAILED",
messageParameters = Map(
"fileName" -> file.toString,
"expectedSize" -> expectedSize.toString,
"expectedChecksum" -> expectedChecksum.toString,
"computedSize" -> computedSize.toString,
"computedChecksum" -> computedChecksum.toString),
cause = null)
}

def cannotReadCheckpoint(expectedVersion: String, actualVersion: String): Throwable = {
new SparkException (
errorClass = "CANNOT_LOAD_STATE_STORE.CANNOT_READ_CHECKPOINT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3126,6 +3126,15 @@ object SQLConf {
.booleanConf
.createWithDefault(true)

val STREAMING_CHECKPOINT_FILE_CHECKSUM_ENABLED =
buildConf("spark.sql.streaming.checkpoint.fileChecksum.enabled")
.internal()
.doc("When true, checksum would be generated and verified for checkpoint files. " +
"This is used to detect file corruption.")
.version("4.1.0")
.booleanConf
.createWithDefault(true)

val PARALLEL_FILE_LISTING_IN_STATS_COMPUTATION =
buildConf("spark.sql.statistics.parallelFileListingInStatsComputation.enabled")
.internal()
Expand Down Expand Up @@ -6044,6 +6053,8 @@ class SQLConf extends Serializable with Logging with SqlApiConf {

def checkpointLocation: Option[String] = getConf(CHECKPOINT_LOCATION)

def checkpointFileChecksumEnabled: Boolean = getConf(STREAMING_CHECKPOINT_FILE_CHECKSUM_ENABLED)

def isUnsupportedOperationCheckEnabled: Boolean = getConf(UNSUPPORTED_OPERATION_CHECK_ENABLED)

def useDeprecatedKafkaOffsetFetching: Boolean = getConf(USE_DEPRECATED_KAFKA_OFFSET_FETCHING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ trait CheckpointFileManager {
* checkpoint path.
*/
def createCheckpointDirectory(): Path

def close(): Unit = {}
}

object CheckpointFileManager extends Logging {
Expand Down
Loading