You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "ericm-db (via GitHub)" <gi...@apache.org> on 2024/08/15 22:13:54 UTC
[PR] Load Column Family Id from RocksDBCheckpointMetadata for VCF when res… [spark]
ericm-db opened a new pull request, #47778:
URL: https://github.com/apache/spark/pull/47778
…tarting, State Store
<!--
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.
-->
### 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.
-->
### 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'.
-->
### 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.
-->
### 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.
-->
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1721176171
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreSuite.scala:
##########
@@ -1026,15 +1026,14 @@ class RocksDBStateStoreSuite extends StateStoreSuiteBase[RocksDBStateStoreProvid
}
}
- // TODO SPARK-48796 after restart state id will not be the same
- ignore(s"get, put, iterator, commit, load with multiple column families") {
+ test(s"get, put, iterator, commit, load with multiple column families") {
Review Comment:
Could we also enable one of the `transformWithState` tests as well around restart ?
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1719373790
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -166,6 +170,81 @@ class RocksDB(
@GuardedBy("acquireLock")
@volatile private var acquiredThreadInfo: AcquiredThreadInfo = _
+ // This is accessed and updated only between load and acquire
+ // which means it is implicitly guarded by acquireLock
+ private val colFamilyNameToIdMap = new ConcurrentHashMap[String, Short]()
+
+ private val defaultColumnFamilyIdMapping =
+ Map(StateStore.DEFAULT_COL_FAMILY_NAME -> StateStore.DEFAULT_COL_FAMILY_ID).asJava
+
+ private val maxColumnFamilyId: AtomicInteger = new AtomicInteger(0)
+
+ private val shouldForceSnapshot: AtomicBoolean = new AtomicBoolean(false)
+
+ def getColFamilyNameToIdMap: Map[String, Short] = {
+ colFamilyNameToIdMap.asScala.toMap
+ }
+
+ /**
+ * Check whether the column family name is for internal column families.
+ *
+ * @param cfName - column family name
+ * @return - true if the column family is for internal use, false otherwise
+ */
+ def checkInternalColumnFamilies(cfName: String): Boolean = cfName.charAt(0) == '_'
+
+ /**
+ * Create RocksDB column family, if not created already
+ */
+ def createColFamilyIfAbsent(colFamilyName: String, isInternal: Boolean = false): Short = {
+ if (!checkColFamilyExists(colFamilyName)) {
+ val newColumnFamilyId = maxColumnFamilyId.incrementAndGet().toShort
+ colFamilyNameToIdMap.putIfAbsent(colFamilyName, newColumnFamilyId)
+ shouldForceSnapshot.set(true)
+ newColumnFamilyId
+ } else colFamilyNameToIdMap.get(colFamilyName)
Review Comment:
nit: can we put this inside a brace ?
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1719370927
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreSuite.scala:
##########
@@ -1090,6 +1089,37 @@ class RocksDBStateStoreSuite extends StateStoreSuiteBase[RocksDBStateStoreProvid
}
}
+
+ test("verify that column family id is assigned correctly after removal") {
+ tryWithProviderResource(newStoreProvider(useColumnFamilies = true)) { provider =>
+ var store = provider.getStore(0)
+ val colFamily1: String = "abc"
+ val colFamily2: String = "def"
+ val colFamily3: String = "ghi"
+ val colFamily4: String = "jkl"
+ val colFamily5: String = "mno"
+ store.createColFamilyIfAbsent(colFamily1, keySchema, valueSchema,
+ NoPrefixKeyStateEncoderSpec(keySchema))
+ store.createColFamilyIfAbsent(colFamily2, keySchema, valueSchema,
+ NoPrefixKeyStateEncoderSpec(keySchema))
+ store.commit()
+
+ store = provider.getStore(1)
+ store.removeColFamilyIfExists(colFamily2)
+ store.commit()
+
+ store = provider.getStore(2)
Review Comment:
can we also check by rolling back to an older version ?
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1721174715
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreProvider.scala:
##########
@@ -498,116 +492,63 @@ private[sql] class RocksDBStateStoreProvider
}
/**
- * Class for column family related utility functions.
- * Verification functions for column family names, column family operation validations etc.
+ * Function to verify invariants for column family based operations
+ * such as get, put, remove etc.
+ *
+ * @param operationName - name of the store operation
+ * @param colFamilyName - name of the column family
*/
- private object ColumnFamilyUtils {
- private val multColFamiliesDisabledStr = "multiple column families is disabled in " +
- "RocksDBStateStoreProvider"
-
- /**
- * Function to verify invariants for column family based operations
- * such as get, put, remove etc.
- *
- * @param operationName - name of the store operation
- * @param colFamilyName - name of the column family
- */
- def verifyColFamilyOperations(
- operationName: String,
- colFamilyName: String): Unit = {
- if (colFamilyName != StateStore.DEFAULT_COL_FAMILY_NAME) {
- // if the state store instance does not support multiple column families, throw an exception
- if (!useColumnFamilies) {
- throw StateStoreErrors.unsupportedOperationException(operationName,
- multColFamiliesDisabledStr)
- }
-
- // if the column family name is empty or contains leading/trailing whitespaces, throw an
- // exception
- if (colFamilyName.isEmpty || colFamilyName.trim != colFamilyName) {
- throw StateStoreErrors.cannotUseColumnFamilyWithInvalidName(operationName, colFamilyName)
- }
-
- // if the column family does not exist, throw an exception
- if (!checkColFamilyExists(colFamilyName)) {
- throw StateStoreErrors.unsupportedOperationOnMissingColumnFamily(operationName,
- colFamilyName)
- }
- }
- }
-
- /**
- * Function to verify invariants for column family creation or deletion operations.
- *
- * @param operationName - name of the store operation
- * @param colFamilyName - name of the column family
- */
- private def verifyColFamilyCreationOrDeletion(
- operationName: String,
- colFamilyName: String,
- isInternal: Boolean = false): Unit = {
+ private def verifyColFamilyOperations(
+ operationName: String,
+ colFamilyName: String): Unit = {
+ if (colFamilyName != StateStore.DEFAULT_COL_FAMILY_NAME) {
// if the state store instance does not support multiple column families, throw an exception
if (!useColumnFamilies) {
throw StateStoreErrors.unsupportedOperationException(operationName,
multColFamiliesDisabledStr)
}
- // if the column family name is empty or contains leading/trailing whitespaces
- // or using the reserved "default" column family, throw an exception
- if (colFamilyName.isEmpty
- || colFamilyName.trim != colFamilyName
- || colFamilyName == StateStore.DEFAULT_COL_FAMILY_NAME) {
+ // if the column family name is empty or contains leading/trailing whitespaces, throw an
+ // exception
+ if (colFamilyName.isEmpty || colFamilyName.trim != colFamilyName) {
throw StateStoreErrors.cannotUseColumnFamilyWithInvalidName(operationName, colFamilyName)
}
- // if the column family is not internal and uses reserved characters, throw an exception
- if (!isInternal && colFamilyName.charAt(0) == '_') {
- throw StateStoreErrors.cannotCreateColumnFamilyWithReservedChars(colFamilyName)
+ // if the column family does not exist, throw an exception
+ if (!rocksDB.checkColFamilyExists(colFamilyName)) {
+ throw StateStoreErrors.unsupportedOperationOnMissingColumnFamily(operationName,
+ colFamilyName)
}
}
+ }
- /**
- * Check whether the column family name is for internal column families.
- *
- * @param cfName - column family name
- * @return - true if the column family is for internal use, false otherwise
- */
- def checkInternalColumnFamilies(cfName: String): Boolean = cfName.charAt(0) == '_'
-
- /**
- * Create RocksDB column family, if not created already
- */
- def createColFamilyIfAbsent(colFamilyName: String, isInternal: Boolean = false):
- Option[Short] = {
- verifyColFamilyCreationOrDeletion("create_col_family", colFamilyName, isInternal)
- if (!checkColFamilyExists(colFamilyName)) {
- val newColumnFamilyId = colFamilyId.incrementAndGet().toShort
- colFamilyNameToIdMap.putIfAbsent(colFamilyName, newColumnFamilyId)
- Option(newColumnFamilyId)
- } else None
+ /**
+ * Function to verify invariants for column family creation or deletion operations.
+ *
+ * @param operationName - name of the store operation
+ * @param colFamilyName - name of the column family
+ */
+ private def verifyColFamilyCreationOrDeletion(
+ operationName: String,
+ colFamilyName: String,
+ isInternal: Boolean = false): Unit = {
+ // if the state store instance does not support multiple column families, throw an exception
+ if (!useColumnFamilies) {
+ throw StateStoreErrors.unsupportedOperationException(operationName,
+ multColFamiliesDisabledStr)
}
- /**
- * Remove RocksDB column family, if exists
- */
- def removeColFamilyIfExists(colFamilyName: String): Boolean = {
- verifyColFamilyCreationOrDeletion("remove_col_family", colFamilyName)
- if (checkColFamilyExists(colFamilyName)) {
- colFamilyNameToIdMap.remove(colFamilyName)
- true
- } else {
- false
- }
+ // if the column family name is empty or contains leading/trailing whitespaces
+ // or using the reserved "default" column family, throw an exception
+ if (colFamilyName.isEmpty
+ || colFamilyName.trim != colFamilyName
Review Comment:
lets use `(` and `)` explicitly ?
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1721346399
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/StateStore.scala:
##########
@@ -126,14 +126,16 @@ trait StateStore extends ReadStateStore {
/**
* Create column family with given name, if absent.
+ *
+ * @return column family ID
*/
def createColFamilyIfAbsent(
colFamilyName: String,
keySchema: StructType,
valueSchema: StructType,
keyStateEncoderSpec: KeyStateEncoderSpec,
useMultipleValuesPerKey: Boolean = false,
- isInternal: Boolean = false): Unit
+ isInternal: Boolean = false): Short
Review Comment:
Can we retain the concept of VCF into RocksDB and do not expose this to the outside of state store? I asked to not break the layer - VCF must be bound to the detail of state store provider.
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreProvider.scala:
##########
@@ -447,9 +440,9 @@ private[sql] class RocksDBStateStoreProvider
private val keyValueEncoderMap = new java.util.concurrent.ConcurrentHashMap[String,
(RocksDBKeyStateEncoder, RocksDBValueStateEncoder)]
- private val colFamilyNameToIdMap = new java.util.concurrent.ConcurrentHashMap[String, Short]
- // TODO SPARK-48796 load column family id from state schema when restarting
- private val colFamilyId = new AtomicInteger(0)
+
Review Comment:
nit: unnecessary empty line
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/StateStore.scala:
##########
@@ -606,6 +608,8 @@ object StateStore extends Logging {
val DEFAULT_COL_FAMILY_NAME = "default"
+ val DEFAULT_COL_FAMILY_ID: Short = 0
Review Comment:
This is not needed if we don't expose this. Again, caller should be able to just deal with column family name.
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreProvider.scala:
##########
@@ -447,9 +440,9 @@ private[sql] class RocksDBStateStoreProvider
private val keyValueEncoderMap = new java.util.concurrent.ConcurrentHashMap[String,
(RocksDBKeyStateEncoder, RocksDBValueStateEncoder)]
- private val colFamilyNameToIdMap = new java.util.concurrent.ConcurrentHashMap[String, Short]
- // TODO SPARK-48796 load column family id from state schema when restarting
- private val colFamilyId = new AtomicInteger(0)
+
+ private val multColFamiliesDisabledStr = "multiple column families is disabled in " +
Review Comment:
nit: mult`i`ColFamiliesDisabledStr
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -166,6 +170,83 @@ class RocksDB(
@GuardedBy("acquireLock")
@volatile private var acquiredThreadInfo: AcquiredThreadInfo = _
+ // This is accessed and updated only between load and acquire
Review Comment:
nit: personally, code comment makes me more confused. The comment says "between load and acquire", what is acquire here? Do you mean by "release"?
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreSuite.scala:
##########
@@ -1090,6 +1098,45 @@ class RocksDBStateStoreSuite extends StateStoreSuiteBase[RocksDBStateStoreProvid
}
}
+
+ test("verify that column family id is assigned correctly after removal") {
+ tryWithProviderResource(newStoreProvider(useColumnFamilies = true)) { provider =>
+ var store = provider.getStore(0)
+ val colFamily1: String = "abc"
+ val colFamily2: String = "def"
+ val colFamily3: String = "ghi"
+ val colFamily4: String = "jkl"
+ val colFamily5: String = "mno"
+ store.createColFamilyIfAbsent(colFamily1, keySchema, valueSchema,
+ NoPrefixKeyStateEncoderSpec(keySchema))
+ store.createColFamilyIfAbsent(colFamily2, keySchema, valueSchema,
+ NoPrefixKeyStateEncoderSpec(keySchema))
+ store.commit()
+
+ store = provider.getStore(1)
+ store.removeColFamilyIfExists(colFamily2)
+ store.commit()
+
+ store = provider.getStore(2)
+ assert(store.createColFamilyIfAbsent(colFamily3, keySchema, valueSchema,
Review Comment:
Shall we expose test scope method to retrieve association between column family name and column family ID instead? Should be only needed in RocksDB State Store.
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -166,6 +170,83 @@ class RocksDB(
@GuardedBy("acquireLock")
@volatile private var acquiredThreadInfo: AcquiredThreadInfo = _
+ // This is accessed and updated only between load and acquire
+ // which means it is implicitly guarded by acquireLock
+ @GuardedBy("acquireLock")
+ private val colFamilyNameToIdMap = new ConcurrentHashMap[String, Short]()
+
+ @GuardedBy("acquireLock")
+ private val defaultColumnFamilyIdMapping =
Review Comment:
This does not need to be bound to StateStore - Column Family is a concept of StateStore but VCF shouldn't be exposed outside of RocksDB state store provider. COLUMN_FAMILY_`ID` should be bound to RocksDB.
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -550,6 +641,12 @@ class RocksDB(
} finally {
changelogWriter = None
}
+ // If we have changed the columnFamilyId mapping, we have set a new
Review Comment:
Shall we cancel the changelog writer when we upload snapshot instead of writing both? It's still not harmful if we succeed to commit changelog but fail to upload snapshot assuming that the batch will be marked as failed, but it's still redundant to commit changelog.
Also, the changelog and the snapshot is not exactly the same (not just a pure replacement), so if there are both changelog and snapshot for the same version, it is giving more confusion, and in worst case, you lost snapshot file by any reason and the query will take changelog and lose the information of column family update.
--
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] Load Column Family Id from RocksDBCheckpointMetadata for VCF when res… [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1719155218
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreProvider.scala:
##########
@@ -62,17 +60,19 @@ private[sql] class RocksDBStateStoreProvider
valueSchema: StructType,
keyStateEncoderSpec: KeyStateEncoderSpec,
useMultipleValuesPerKey: Boolean = false,
- isInternal: Boolean = false): Unit = {
- val newColFamilyId = ColumnFamilyUtils.createColFamilyIfAbsent(colFamilyName, isInternal)
+ isInternal: Boolean = false): Short = {
+ val newColFamilyId = rocksDB.createColFamilyIfAbsent(colFamilyName, isInternal)
keyValueEncoderMap.putIfAbsent(colFamilyName,
- (RocksDBStateEncoder.getKeyEncoder(keyStateEncoderSpec, useColumnFamilies, newColFamilyId),
- RocksDBStateEncoder.getValueEncoder(valueSchema, useMultipleValuesPerKey)))
+ (RocksDBStateEncoder.getKeyEncoder(keyStateEncoderSpec, useColumnFamilies,
+ Some(newColFamilyId)), RocksDBStateEncoder.getValueEncoder(valueSchema,
+ useMultipleValuesPerKey)))
+ newColFamilyId
}
override def get(key: UnsafeRow, colFamilyName: String): UnsafeRow = {
verify(key != null, "Key cannot be null")
- ColumnFamilyUtils.verifyColFamilyOperations("get", colFamilyName)
+ rocksDB.verifyColFamilyOperations("get", colFamilyName)
Review Comment:
we can refactor this a little bit right ? we don't need to call into the store. just move those functions to the provider ?
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1721258875
##########
sql/core/src/test/scala/org/apache/spark/sql/streaming/TransformWithStateSuite.scala:
##########
@@ -1233,6 +1233,88 @@ class TransformWithStateSuite extends StateStoreMetricsTest
}
}
+ test("test query restart with new state variable succeeds") {
+ withSQLConf(SQLConf.STATE_STORE_PROVIDER_CLASS.key ->
+ classOf[RocksDBStateStoreProvider].getName,
+ SQLConf.SHUFFLE_PARTITIONS.key ->
+ TransformWithStateSuiteUtils.NUM_SHUFFLE_PARTITIONS.toString) {
+ withTempDir { checkpointDir =>
+ val clock = new StreamManualClock
+
+ val inputData1 = MemoryStream[String]
+ val result1 = inputData1.toDS()
+ .groupByKey(x => x)
+ .transformWithState(new RunningCountStatefulProcessor(),
+ TimeMode.ProcessingTime(),
+ OutputMode.Update())
+
+ testStream(result1, OutputMode.Update())(
+ StartStream(
+ checkpointLocation = checkpointDir.getCanonicalPath,
+ trigger = Trigger.ProcessingTime("1 second"),
+ triggerClock = clock),
+ AddData(inputData1, "a"),
+ AdvanceManualClock(1 * 1000),
+ CheckNewAnswer(("a", "1")),
+ StopStream
+ )
+
+
Review Comment:
nit: extra newline ?
--
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] Load Column Family Id from RocksDBCheckpointMetadata for VCF when res… [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1719155745
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreProvider.scala:
##########
@@ -248,13 +248,13 @@ private[sql] class RocksDBStateStoreProvider
// Used for metrics reporting around internal/external column families
def internalColFamilyCnt(): Long = {
- colFamilyNameToIdMap.keys.asScala.toSeq
- .filter(ColumnFamilyUtils.checkInternalColumnFamilies(_)).size
+ rocksDB.getColFamilyNameToIdMap.keys.
Review Comment:
rather just define the function within the store. something like
```
rocksDB.getColFamilyCount(bool internal)
```
--
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] Load Column Family Id from RocksDBCheckpointMetadata for VCF when res… [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #47778:
URL: https://github.com/apache/spark/pull/47778#issuecomment-2292521919
Mind filing a JIRA and adding it into the PR title?
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "ericm-db (via GitHub)" <gi...@apache.org>.
ericm-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1719381132
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -19,11 +19,13 @@ package org.apache.spark.sql.execution.streaming.state
import java.io.File
import java.util.Locale
-import java.util.concurrent.TimeUnit
+import java.util.concurrent.{ConcurrentHashMap, TimeUnit}
+import java.util.concurrent.atomic.{AtomicBoolean, AtomicInteger}
import javax.annotation.concurrent.GuardedBy
import scala.collection.{mutable, Map}
import scala.collection.mutable.ListBuffer
+import scala.jdk.CollectionConverters.{ConcurrentMapHasAsScala, MapHasAsJava}
Review Comment:
It's used right here: https://github.com/apache/spark/pull/47778/files#diff-4663b8349511dc040c3d5204bb6868064002d0b45aadaf1f1795a683897a5c7dR242
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1721437164
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -550,6 +641,12 @@ class RocksDB(
} finally {
changelogWriter = None
}
+ // If we have changed the columnFamilyId mapping, we have set a new
Review Comment:
Shall we cancel the changelog writer when we upload snapshot instead of writing both? It's still not harmful if we succeed to commit changelog but fail to upload snapshot assuming that the batch will be marked as failed, but it's still redundant to commit changelog.
Also, the changelog and the snapshot is not exactly the same (not just a pure replacement), so if there are both changelog and snapshot for the same version, it is giving more confusion, and in worst case, you lost snapshot file by any reason and the query will take changelog and lose the information of column family update, instead of failing query (proper expectation).
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "ericm-db (via GitHub)" <gi...@apache.org>.
ericm-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1722498110
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/StateStore.scala:
##########
@@ -135,7 +135,14 @@ trait StateStore extends ReadStateStore {
valueSchema: StructType,
keyStateEncoderSpec: KeyStateEncoderSpec,
useMultipleValuesPerKey: Boolean = false,
- isInternal: Boolean = false): Short
+ isInternal: Boolean = false): Unit
+
+ // Test-visible methods to fetch column family mapping for this State Store version
Review Comment:
Okay sure
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1719377556
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -166,6 +170,81 @@ class RocksDB(
@GuardedBy("acquireLock")
@volatile private var acquiredThreadInfo: AcquiredThreadInfo = _
+ // This is accessed and updated only between load and acquire
+ // which means it is implicitly guarded by acquireLock
+ private val colFamilyNameToIdMap = new ConcurrentHashMap[String, Short]()
+
+ private val defaultColumnFamilyIdMapping =
+ Map(StateStore.DEFAULT_COL_FAMILY_NAME -> StateStore.DEFAULT_COL_FAMILY_ID).asJava
+
+ private val maxColumnFamilyId: AtomicInteger = new AtomicInteger(0)
+
+ private val shouldForceSnapshot: AtomicBoolean = new AtomicBoolean(false)
+
+ def getColFamilyNameToIdMap: Map[String, Short] = {
+ colFamilyNameToIdMap.asScala.toMap
+ }
+
+ /**
+ * Check whether the column family name is for internal column families.
+ *
+ * @param cfName - column family name
+ * @return - true if the column family is for internal use, false otherwise
+ */
+ def checkInternalColumnFamilies(cfName: String): Boolean = cfName.charAt(0) == '_'
+
+ /**
+ * Create RocksDB column family, if not created already
+ */
+ def createColFamilyIfAbsent(colFamilyName: String, isInternal: Boolean = false): Short = {
+ if (!checkColFamilyExists(colFamilyName)) {
+ val newColumnFamilyId = maxColumnFamilyId.incrementAndGet().toShort
Review Comment:
Do we not need to set `maxColumnFamilyId` to `newColumnFamilyId` ?
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1722496267
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/StateStore.scala:
##########
@@ -135,7 +135,14 @@ trait StateStore extends ReadStateStore {
valueSchema: StructType,
keyStateEncoderSpec: KeyStateEncoderSpec,
useMultipleValuesPerKey: Boolean = false,
- isInternal: Boolean = false): Short
+ isInternal: Boolean = false): Unit
+
+ // Test-visible methods to fetch column family mapping for this State Store version
Review Comment:
Shall we put this into RocksDBStateStore and in test we perform explicit type conversion to RocksDBStateStore? This still put the concept of column family ID into top level of StateStore interface.
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -635,17 +639,19 @@ class RocksDB(
logInfo(log"Syncing checkpoint for ${MDC(LogKeys.VERSION_NUM, newVersion)} to DFS")
val fileSyncTimeMs = timeTakenMs {
if (enableChangelogCheckpointing) {
- try {
- assert(changelogWriter.isDefined)
- changelogWriter.foreach(_.commit())
- } finally {
- changelogWriter = None
- }
// If we have changed the columnFamilyId mapping, we have set a new
// snapshot and need to upload this to the DFS even if changelog checkpointing
// is enabled.
if (shouldForceSnapshot.get()) {
uploadSnapshot()
+ changelogWriter = None
Review Comment:
nit: Let's explicitly call changelogWriter.foreach(_.abort()) to clean up resource properly.
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "ericm-db (via GitHub)" <gi...@apache.org>.
ericm-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1722549798
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -635,17 +639,19 @@ class RocksDB(
logInfo(log"Syncing checkpoint for ${MDC(LogKeys.VERSION_NUM, newVersion)} to DFS")
val fileSyncTimeMs = timeTakenMs {
if (enableChangelogCheckpointing) {
- try {
- assert(changelogWriter.isDefined)
- changelogWriter.foreach(_.commit())
- } finally {
- changelogWriter = None
- }
// If we have changed the columnFamilyId mapping, we have set a new
// snapshot and need to upload this to the DFS even if changelog checkpointing
// is enabled.
if (shouldForceSnapshot.get()) {
uploadSnapshot()
+ changelogWriter = None
Review Comment:
Done
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "ericm-db (via GitHub)" <gi...@apache.org>.
ericm-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1719380196
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -166,6 +170,81 @@ class RocksDB(
@GuardedBy("acquireLock")
@volatile private var acquiredThreadInfo: AcquiredThreadInfo = _
+ // This is accessed and updated only between load and acquire
+ // which means it is implicitly guarded by acquireLock
+ private val colFamilyNameToIdMap = new ConcurrentHashMap[String, Short]()
+
+ private val defaultColumnFamilyIdMapping =
+ Map(StateStore.DEFAULT_COL_FAMILY_NAME -> StateStore.DEFAULT_COL_FAMILY_ID).asJava
+
+ private val maxColumnFamilyId: AtomicInteger = new AtomicInteger(0)
+
+ private val shouldForceSnapshot: AtomicBoolean = new AtomicBoolean(false)
+
+ def getColFamilyNameToIdMap: Map[String, Short] = {
+ colFamilyNameToIdMap.asScala.toMap
+ }
+
+ /**
+ * Check whether the column family name is for internal column families.
+ *
+ * @param cfName - column family name
+ * @return - true if the column family is for internal use, false otherwise
+ */
+ def checkInternalColumnFamilies(cfName: String): Boolean = cfName.charAt(0) == '_'
+
+ /**
+ * Create RocksDB column family, if not created already
+ */
+ def createColFamilyIfAbsent(colFamilyName: String, isInternal: Boolean = false): Short = {
+ if (!checkColFamilyExists(colFamilyName)) {
+ val newColumnFamilyId = maxColumnFamilyId.incrementAndGet().toShort
Review Comment:
Calling `incrementAndGet` sets `maxColFamilyId = maxColFamilyId + 1` and returns that value so I think we're good there
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1721173385
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -166,6 +170,79 @@ class RocksDB(
@GuardedBy("acquireLock")
@volatile private var acquiredThreadInfo: AcquiredThreadInfo = _
+ // This is accessed and updated only between load and acquire
+ // which means it is implicitly guarded by acquireLock
+ private val colFamilyNameToIdMap = new ConcurrentHashMap[String, Short]()
+
+ private val defaultColumnFamilyIdMapping =
+ Map(StateStore.DEFAULT_COL_FAMILY_NAME -> StateStore.DEFAULT_COL_FAMILY_ID).asJava
+
+ private val maxColumnFamilyId: AtomicInteger = new AtomicInteger(0)
+
+ private val shouldForceSnapshot: AtomicBoolean = new AtomicBoolean(false)
+
+ /**
+ * Check whether the column family name is for internal column families.
+ *
+ * @param cfName - column family name
+ * @return - true if the column family is for internal use, false otherwise
+ */
+ def checkInternalColumnFamilies(cfName: String): Boolean = cfName.charAt(0) == '_'
Review Comment:
can these be `private` ?
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1721346399
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/StateStore.scala:
##########
@@ -126,14 +126,16 @@ trait StateStore extends ReadStateStore {
/**
* Create column family with given name, if absent.
+ *
+ * @return column family ID
*/
def createColFamilyIfAbsent(
colFamilyName: String,
keySchema: StructType,
valueSchema: StructType,
keyStateEncoderSpec: KeyStateEncoderSpec,
useMultipleValuesPerKey: Boolean = false,
- isInternal: Boolean = false): Unit
+ isInternal: Boolean = false): Short
Review Comment:
Can we retain the concept of VCF into RocksDB and do not expose this to the outside of state store? I asked to not break the layer - VCF must be bound to the detail of state store provider "implementation".
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1719371598
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -19,11 +19,13 @@ package org.apache.spark.sql.execution.streaming.state
import java.io.File
import java.util.Locale
-import java.util.concurrent.TimeUnit
+import java.util.concurrent.{ConcurrentHashMap, TimeUnit}
+import java.util.concurrent.atomic.{AtomicBoolean, AtomicInteger}
import javax.annotation.concurrent.GuardedBy
import scala.collection.{mutable, Map}
import scala.collection.mutable.ListBuffer
+import scala.jdk.CollectionConverters.{ConcurrentMapHasAsScala, MapHasAsJava}
Review Comment:
Where is this used ?
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR closed pull request #47778: [SPARK-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting
URL: https://github.com/apache/spark/pull/47778
--
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] Load Column Family Id from RocksDBCheckpointMetadata for VCF when res… [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1719156773
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -188,6 +313,13 @@ class RocksDB(
// Initialize maxVersion upon successful load from DFS
fileManager.setMaxSeenVersion(version)
+ metadata.columnFamilyMapping.foreach { mapping =>
Review Comment:
We need to clear this map first right ?
```
colFamilyNameToIdMap.clear()
```
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1721173178
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -166,6 +170,79 @@ class RocksDB(
@GuardedBy("acquireLock")
@volatile private var acquiredThreadInfo: AcquiredThreadInfo = _
+ // This is accessed and updated only between load and acquire
+ // which means it is implicitly guarded by acquireLock
+ private val colFamilyNameToIdMap = new ConcurrentHashMap[String, Short]()
+
+ private val defaultColumnFamilyIdMapping =
+ Map(StateStore.DEFAULT_COL_FAMILY_NAME -> StateStore.DEFAULT_COL_FAMILY_ID).asJava
+
+ private val maxColumnFamilyId: AtomicInteger = new AtomicInteger(0)
Review Comment:
Lets specify `@GuardedBy("acquireLock")` for all of these ?
--
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] Load Column Family Id from RocksDBCheckpointMetadata for VCF when res… [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1719156978
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -166,6 +170,127 @@ class RocksDB(
@GuardedBy("acquireLock")
@volatile private var acquiredThreadInfo: AcquiredThreadInfo = _
+ // make visible for testing
+ private val colFamilyNameToIdMap = new ConcurrentHashMap[String, Short](
Review Comment:
Is this also guarded by `acquireLock` ?
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1721173858
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -550,6 +637,9 @@ class RocksDB(
} finally {
changelogWriter = None
}
+ if (shouldForceSnapshot.get()) {
Review Comment:
can we add a comment here to explain why this necessary ?
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1721824474
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -166,6 +170,83 @@ class RocksDB(
@GuardedBy("acquireLock")
@volatile private var acquiredThreadInfo: AcquiredThreadInfo = _
+ // This is accessed and updated only between load and acquire
+ // which means it is implicitly guarded by acquireLock
+ @GuardedBy("acquireLock")
+ private val colFamilyNameToIdMap = new ConcurrentHashMap[String, Short]()
+
+ @GuardedBy("acquireLock")
+ private val defaultColumnFamilyIdMapping =
Review Comment:
I meant the value of element in the map, in case you might be confused.
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1719383828
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -188,6 +267,14 @@ class RocksDB(
// Initialize maxVersion upon successful load from DFS
fileManager.setMaxSeenVersion(version)
+ setInitialCFInfo()
+ metadata.columnFamilyMapping.foreach { mapping =>
+ colFamilyNameToIdMap.putAll(mapping.asJava)
+ }
+
+ metadata.maxColumnFamilyId.foreach { maxId =>
Review Comment:
Do we need to do `foreach` ?
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1721174370
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreProvider.scala:
##########
@@ -248,13 +249,11 @@ private[sql] class RocksDBStateStoreProvider
// Used for metrics reporting around internal/external column families
def internalColFamilyCnt(): Long = {
- colFamilyNameToIdMap.keys.asScala.toSeq
- .filter(ColumnFamilyUtils.checkInternalColumnFamilies(_)).size
+ rocksDB.getColFamilyCount(true)
Review Comment:
lets mention the arg explicitly ?
`isInternal = true` ?
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "ericm-db (via GitHub)" <gi...@apache.org>.
ericm-db commented on PR #47778:
URL: https://github.com/apache/spark/pull/47778#issuecomment-2295747175
@HeartSaVioR Could you PTAL when you get a chance?
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "ericm-db (via GitHub)" <gi...@apache.org>.
ericm-db commented on code in PR #47778:
URL: https://github.com/apache/spark/pull/47778#discussion_r1719430396
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -188,6 +267,14 @@ class RocksDB(
// Initialize maxVersion upon successful load from DFS
fileManager.setMaxSeenVersion(version)
+ setInitialCFInfo()
+ metadata.columnFamilyMapping.foreach { mapping =>
+ colFamilyNameToIdMap.putAll(mapping.asJava)
+ }
+
+ metadata.maxColumnFamilyId.foreach { maxId =>
Review Comment:
Yeah because we're reading an option right
--
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-48796][SS] Load Column Family Id from RocksDBCheckpointMetadata for VCF when restarting [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on PR #47778:
URL: https://github.com/apache/spark/pull/47778#issuecomment-2297853884
Thanks! Merging to master.
--
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