You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "WweiL (via GitHub)" <gi...@apache.org> on 2024/12/23 17:43:09 UTC

[PR] [SPARK-50652][SS] Add checks to RocksDB V2 backward compatibility [spark]

WweiL opened a new pull request, #49275:
URL: https://github.com/apache/spark/pull/49275

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'common/utils/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   Currently in rocksDB level, v2 -> v1 backward compatibility is not supported. This PR adds a exact version check in commit log level for this purpose. 
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   For compatibility check
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   No
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   Modify test cases and filed followups 
   
   ### Was this patch authored or co-authored using generative AI tooling?
   <!--
   If generative AI tooling has been used in the process of authoring this patch, please include the
   phrase: 'Generated-by: ' followed by the name of the tool and its version.
   If no, write 'No'.
   Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   No


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50652][SS] Add checks to RocksDB V2 backward compatibility [spark]

Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR closed pull request #49275: [SPARK-50652][SS] Add checks to RocksDB V2 backward compatibility
URL: https://github.com/apache/spark/pull/49275


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50652][SS] Add checks to RocksDB V2 backward compatibility [spark]

Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on PR #49275:
URL: https://github.com/apache/spark/pull/49275#issuecomment-2599265195

   Thanks, I'm merging on behalf of @brkyvz . Merging to master/4.0.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50652][SS] Add checks to RocksDB V2 backward compatibility [spark]

Posted by "brkyvz (via GitHub)" <gi...@apache.org>.
brkyvz commented on code in PR #49275:
URL: https://github.com/apache/spark/pull/49275#discussion_r1915413736


##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -2825,6 +2825,30 @@
     },
     "sqlState" : "42K0E"
   },
+  "INVALID_LOG_VERSION" : {
+    "message" : [
+      "UnsupportedLogVersion."
+    ],
+    "subClass" : {
+      "EXACT_MATCH_VERSION" : {
+        "message" : [
+          "The only supported log version is v<matchVersion>, but encountered v<version>."
+        ]
+      },
+      "MAX_SUPPORTED_VERSION" : {
+        "message" : [
+          "The maximum supported log version is v<maxSupportedVersion>, but encountered v<version>. The log file was produced by a newer version of Spark and cannot be read by this version. You need to upgrade."
+        ]
+      }
+    },
+    "sqlState" : "KD002"
+  },
+  "INVALID_METADATA_VERSION" : {

Review Comment:
   `MALFORMED_LOG_FILE`?



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala:
##########
@@ -2631,6 +2631,34 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase with ExecutionE
       cause = null)
   }
 
+  def invalidMetadataVersion(text: String): Throwable = {
+    new SparkIllegalStateException(
+      errorClass = "INVALID_METADATA_VERSION",
+      messageParameters = Map("text" -> text),
+      cause = null
+    )
+  }
+
+  def invalidLogVersion(version: Int, maxSupportedVersion: Int): Throwable = {
+    new SparkIllegalStateException(
+      errorClass = "INVALID_LOG_VERSION.MAX_SUPPORTED_VERSION",
+      messageParameters = Map(
+        "version" -> version.toString,
+        "maxSupportedVersion" -> maxSupportedVersion.toString),
+      cause = null
+    )
+  }
+
+  def invalidLogVersionExactMatch(version: Int, matchVersion: Int): Throwable = {

Review Comment:
   logVersionNotMatch



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala:
##########
@@ -2631,6 +2631,34 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase with ExecutionE
       cause = null)
   }
 
+  def invalidMetadataVersion(text: String): Throwable = {
+    new SparkIllegalStateException(
+      errorClass = "INVALID_METADATA_VERSION",
+      messageParameters = Map("text" -> text),
+      cause = null
+    )
+  }
+
+  def invalidLogVersion(version: Int, maxSupportedVersion: Int): Throwable = {

Review Comment:
   logVersionGreaterThanSupported



##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/CommitLog.scala:
##########
@@ -51,14 +51,19 @@ class CommitLog(sparkSession: SparkSession, path: String)
 
   import CommitLog._
 
+  private val VERSION: Int = sparkSession.conf.get(
+    SQLConf.STATE_STORE_CHECKPOINT_FORMAT_VERSION.key).toInt
+
   override protected[sql] def deserialize(in: InputStream): CommitMetadata = {
     // called inside a try-finally where the underlying stream is closed in the caller
     val lines = IOSource.fromInputStream(in, UTF_8.name()).getLines()
     if (!lines.hasNext) {
       throw new IllegalStateException("Incomplete log file in the offset commit log")
     }
     // TODO [SPARK-49462] This validation should be relaxed for a stateless query.
-    validateVersion(lines.next().trim, VERSION)
+    // TODO [SPARK-50653] This validation should be relaxed to support reading
+    //  a V1 log file when VERSION is V2
+    validateVersionExactMatch(lines.next().trim, VERSION)

Review Comment:
   what's the work necessary for this? Why doesn't it just work? Can't we just fix it here?



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50652][SS] Add checks to RocksDB V2 backward compatibility [spark]

Posted by "siying (via GitHub)" <gi...@apache.org>.
siying commented on code in PR #49275:
URL: https://github.com/apache/spark/pull/49275#discussion_r1904693483


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/CommitLog.scala:
##########
@@ -51,14 +51,18 @@ class CommitLog(sparkSession: SparkSession, path: String)
 
   import CommitLog._
 
+  private val VERSION = SQLConf.get.stateStoreCheckpointFormatVersion

Review Comment:
   What's the purpose of moving this variable to here?



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50652][SS] Add checks to RocksDB V2 backward compatibility [spark]

Posted by "brkyvz (via GitHub)" <gi...@apache.org>.
brkyvz commented on code in PR #49275:
URL: https://github.com/apache/spark/pull/49275#discussion_r1906538392


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/MetadataVersionUtil.scala:
##########
@@ -20,32 +20,52 @@ package org.apache.spark.sql.execution.streaming
 object MetadataVersionUtil {
   /**
    * Parse the log version from the given `text` -- will throw exception when the parsed version
-   * exceeds `maxSupportedVersion`, or when `text` is malformed (such as "xyz", "v", "v-1",
-   * "v123xyz" etc.)
+   * exceeds `maxSupportedVersion`, or when `text` is malformed.
    */
   def validateVersion(text: String, maxSupportedVersion: Int): Int = {
-    if (text.length > 0 && text(0) == 'v') {
-      val version =
-        try {
-          text.substring(1, text.length).toInt
-        } catch {
-          case _: NumberFormatException =>
-            throw new IllegalStateException(s"Log file was malformed: failed to read correct log " +
-              s"version from $text.")
-        }
-      if (version > 0) {
-        if (version > maxSupportedVersion) {
-          throw new IllegalStateException(s"UnsupportedLogVersion: maximum supported log version " +
-            s"is v${maxSupportedVersion}, but encountered v$version. The log file was produced " +
-            s"by a newer version of Spark and cannot be read by this version. Please upgrade.")
-        } else {
-          return version
-        }
-      }
+    val version: Int = extractVersion(text)
+    if (version > maxSupportedVersion) {
+      throw new IllegalStateException(s"UnsupportedLogVersion: maximum supported log version " +
+        s"is v${maxSupportedVersion}, but encountered v$version. The log file was produced " +
+        s"by a newer version of Spark and cannot be read by this version. Please upgrade.")
+    }
+    version
+  }
+
+  /**
+   * Parse the log version from the given `text` -- will throw exception when the parsed version
+   * does not equal to `matchVersion`, or when `text` is malformed.
+   */
+  def validateVersionExactMatch(text: String, matchVersion: Int): Int = {
+    val version: Int = extractVersion(text)
+    if (version != matchVersion) {
+      throw new IllegalStateException(s"UnsupportedLogVersion: the only supported log version " +
+        s"is v${matchVersion}, but encountered v$version.")

Review Comment:
   please use the new error message framework



##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/CommitLog.scala:
##########
@@ -51,14 +51,18 @@ class CommitLog(sparkSession: SparkSession, path: String)
 
   import CommitLog._
 
+  private val VERSION = SQLConf.get.stateStoreCheckpointFormatVersion

Review Comment:
   I think moving it here is correct since the conf can be changed per session. Can we use `sparkSession.conf` instead though, not SQLConf.get?



##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/MetadataVersionUtil.scala:
##########
@@ -20,32 +20,52 @@ package org.apache.spark.sql.execution.streaming
 object MetadataVersionUtil {
   /**
    * Parse the log version from the given `text` -- will throw exception when the parsed version
-   * exceeds `maxSupportedVersion`, or when `text` is malformed (such as "xyz", "v", "v-1",
-   * "v123xyz" etc.)
+   * exceeds `maxSupportedVersion`, or when `text` is malformed.
    */
   def validateVersion(text: String, maxSupportedVersion: Int): Int = {
-    if (text.length > 0 && text(0) == 'v') {
-      val version =
-        try {
-          text.substring(1, text.length).toInt
-        } catch {
-          case _: NumberFormatException =>
-            throw new IllegalStateException(s"Log file was malformed: failed to read correct log " +
-              s"version from $text.")
-        }
-      if (version > 0) {
-        if (version > maxSupportedVersion) {
-          throw new IllegalStateException(s"UnsupportedLogVersion: maximum supported log version " +
-            s"is v${maxSupportedVersion}, but encountered v$version. The log file was produced " +
-            s"by a newer version of Spark and cannot be read by this version. Please upgrade.")
-        } else {
-          return version
-        }
-      }
+    val version: Int = extractVersion(text)
+    if (version > maxSupportedVersion) {
+      throw new IllegalStateException(s"UnsupportedLogVersion: maximum supported log version " +
+        s"is v${maxSupportedVersion}, but encountered v$version. The log file was produced " +
+        s"by a newer version of Spark and cannot be read by this version. Please upgrade.")
+    }
+    version
+  }
+
+  /**
+   * Parse the log version from the given `text` -- will throw exception when the parsed version
+   * does not equal to `matchVersion`, or when `text` is malformed.
+   */
+  def validateVersionExactMatch(text: String, matchVersion: Int): Int = {
+    val version: Int = extractVersion(text)
+    if (version != matchVersion) {
+      throw new IllegalStateException(s"UnsupportedLogVersion: the only supported log version " +
+        s"is v${matchVersion}, but encountered v$version.")
     }
+    version
+  }
 
-    // reaching here means we failed to read the correct log version
-    throw new IllegalStateException(s"Log file was malformed: failed to read correct log " +
-      s"version from $text.")
+  /**
+   * Parse the log version from the given `text` -- will throw exception when the parsed version
+   * when `text` is malformed (such as "xyz", "v", "v-1", "v123xyz" etc.)
+   */
+  private def extractVersion(text: String): Int = {
+    val version: Int = if (text.nonEmpty && text(0) == 'v') {
+      try {
+        text.substring(1, text.length).toInt
+      } catch {
+        case _: NumberFormatException =>
+          throw new IllegalStateException(s"Log file was malformed: failed to read correct log " +
+            s"version from $text.")
+      }
+    } else {
+      throw new IllegalStateException(s"Log file was malformed: failed to read correct log " +
+        s"version from $text.")
+    }
+    if (version <= 0) {
+      throw new IllegalStateException(s"Log file was malformed: failed to read correct log " +
+        s"version from $text.")
+    }

Review Comment:
   Can you please use the new error framework for these errors?



##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/MetadataVersionUtil.scala:
##########
@@ -20,32 +20,52 @@ package org.apache.spark.sql.execution.streaming
 object MetadataVersionUtil {
   /**
    * Parse the log version from the given `text` -- will throw exception when the parsed version
-   * exceeds `maxSupportedVersion`, or when `text` is malformed (such as "xyz", "v", "v-1",
-   * "v123xyz" etc.)
+   * exceeds `maxSupportedVersion`, or when `text` is malformed.
    */
   def validateVersion(text: String, maxSupportedVersion: Int): Int = {
-    if (text.length > 0 && text(0) == 'v') {
-      val version =
-        try {
-          text.substring(1, text.length).toInt
-        } catch {
-          case _: NumberFormatException =>
-            throw new IllegalStateException(s"Log file was malformed: failed to read correct log " +
-              s"version from $text.")
-        }
-      if (version > 0) {
-        if (version > maxSupportedVersion) {
-          throw new IllegalStateException(s"UnsupportedLogVersion: maximum supported log version " +
-            s"is v${maxSupportedVersion}, but encountered v$version. The log file was produced " +
-            s"by a newer version of Spark and cannot be read by this version. Please upgrade.")
-        } else {
-          return version
-        }
-      }
+    val version: Int = extractVersion(text)
+    if (version > maxSupportedVersion) {
+      throw new IllegalStateException(s"UnsupportedLogVersion: maximum supported log version " +
+        s"is v${maxSupportedVersion}, but encountered v$version. The log file was produced " +
+        s"by a newer version of Spark and cannot be read by this version. Please upgrade.")

Review Comment:
   please use the new error message framework for 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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50652][SS] Add checks to RocksDB V2 backward compatibility [spark]

Posted by "srielau (via GitHub)" <gi...@apache.org>.
srielau commented on code in PR #49275:
URL: https://github.com/apache/spark/pull/49275#discussion_r1911592696


##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -2800,6 +2800,30 @@
     },
     "sqlState" : "42K0E"
   },
+  "INVALID_LOG_VERSION" : {
+    "message" : [
+      "UnsupportedLogVersion."
+    ],
+    "subClass" : {
+      "EXACT_MATCH_VERSION" : {
+        "message" : [
+          "the only supported log version is v<matchVersion>, but encountered v<version>."
+        ]
+      },
+      "MAX_SUPPORTED_VERSION" : {
+        "message" : [
+          "maximum supported log version is v<maxSupportedVersion>, but encountered v<version>. The log file was produced by a newer version of Spark and cannot be read by this version. Please upgrade."
+        ]
+      }
+    },
+    "sqlState" : "22023"

Review Comment:
   ```suggestion
       "sqlState" : "KD002"
   ```
   
   Unexpected Version



##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -2800,6 +2800,30 @@
     },
     "sqlState" : "42K0E"
   },
+  "INVALID_LOG_VERSION" : {
+    "message" : [
+      "UnsupportedLogVersion."
+    ],
+    "subClass" : {
+      "EXACT_MATCH_VERSION" : {
+        "message" : [
+          "the only supported log version is v<matchVersion>, but encountered v<version>."

Review Comment:
   ```suggestion
             "The only supported log version is v<matchVersion>, but encountered v<version>."
   ```



##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -2800,6 +2800,30 @@
     },
     "sqlState" : "42K0E"
   },
+  "INVALID_LOG_VERSION" : {
+    "message" : [
+      "UnsupportedLogVersion."
+    ],
+    "subClass" : {
+      "EXACT_MATCH_VERSION" : {
+        "message" : [
+          "the only supported log version is v<matchVersion>, but encountered v<version>."
+        ]
+      },
+      "MAX_SUPPORTED_VERSION" : {
+        "message" : [
+          "maximum supported log version is v<maxSupportedVersion>, but encountered v<version>. The log file was produced by a newer version of Spark and cannot be read by this version. Please upgrade."
+        ]
+      }
+    },
+    "sqlState" : "22023"
+  },
+  "INVALID_METADATA_VERSION" : {
+    "message" : [
+      "Log file was malformed: failed to read correct log version from <text>."
+    ],
+    "sqlState" : "22023"

Review Comment:
   ```suggestion
       "sqlState" : "KD002"
   ```



##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -2800,6 +2800,30 @@
     },
     "sqlState" : "42K0E"
   },
+  "INVALID_LOG_VERSION" : {
+    "message" : [
+      "UnsupportedLogVersion."
+    ],
+    "subClass" : {
+      "EXACT_MATCH_VERSION" : {
+        "message" : [
+          "the only supported log version is v<matchVersion>, but encountered v<version>."
+        ]
+      },
+      "MAX_SUPPORTED_VERSION" : {
+        "message" : [
+          "maximum supported log version is v<maxSupportedVersion>, but encountered v<version>. The log file was produced by a newer version of Spark and cannot be read by this version. Please upgrade."

Review Comment:
   ```suggestion
             "The maximum supported log version is v<maxSupportedVersion>, but encountered v<version>. The log file was produced by a newer version of Spark and cannot be read by this version. You need to upgrade."
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50652][SS] Add checks to RocksDB V2 backward compatibility [spark]

Posted by "WweiL (via GitHub)" <gi...@apache.org>.
WweiL commented on PR #49275:
URL: https://github.com/apache/spark/pull/49275#issuecomment-2584046369

   Ended up creating a new error framework because [we have existing tests expecting IllegalStateException](https://github.com/apache/spark/blob/ef37f9a8e202812ea6b710bfb084ce176ff5e63d/connector/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaMicroBatchSourceSuite.scala#L1005). Also there might be some test cases used by downstream projects expecting the same @brkyvz 


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50652][SS] Add checks to RocksDB V2 backward compatibility [spark]

Posted by "WweiL (via GitHub)" <gi...@apache.org>.
WweiL commented on code in PR #49275:
URL: https://github.com/apache/spark/pull/49275#discussion_r1915520560


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/CommitLog.scala:
##########
@@ -51,14 +51,19 @@ class CommitLog(sparkSession: SparkSession, path: String)
 
   import CommitLog._
 
+  private val VERSION: Int = sparkSession.conf.get(
+    SQLConf.STATE_STORE_CHECKPOINT_FORMAT_VERSION.key).toInt
+
   override protected[sql] def deserialize(in: InputStream): CommitMetadata = {
     // called inside a try-finally where the underlying stream is closed in the caller
     val lines = IOSource.fromInputStream(in, UTF_8.name()).getLines()
     if (!lines.hasNext) {
       throw new IllegalStateException("Incomplete log file in the offset commit log")
     }
     // TODO [SPARK-49462] This validation should be relaxed for a stateless query.
-    validateVersion(lines.next().trim, VERSION)
+    // TODO [SPARK-50653] This validation should be relaxed to support reading
+    //  a V1 log file when VERSION is V2
+    validateVersionExactMatch(lines.next().trim, VERSION)

Review Comment:
   follow up jira filed here https://issues.apache.org/jira/browse/SPARK-50653
   Originally I tried to make it just work, but after the refactor requested, it doesn't work anymore. 
   
   Making it work would require some logic change in RocksDB file now, @siying mentinoed that there should be a one-time snapshot for the v1 -> v2 case. So I filed a ticket and mark this as todo for now.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50652][SS] Add checks to RocksDB V2 backward compatibility [spark]

Posted by "brkyvz (via GitHub)" <gi...@apache.org>.
brkyvz commented on code in PR #49275:
URL: https://github.com/apache/spark/pull/49275#discussion_r1915533277


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala:
##########
@@ -2631,6 +2631,34 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase with ExecutionE
       cause = null)
   }
 
+  def invalidMetadataVersion(text: String): Throwable = {

Review Comment:
   maybe rename this to `malformedLogFile` too



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org