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 2025/08/13 20:57:10 UTC
[PR] [SPARK-53276] Checking if we own the stamp before closing RocksDB [spark]
ericm-db opened a new pull request, #52018:
URL: https://github.com/apache/spark/pull/52018
<!--
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.
-->
Checking if we own the lock before closing the RocksDB instance.
### 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.
-->
Currently, we don't check whether we own the state machine stamp to close the store, which can lead to incorrect behavior (i.e closing during active commit) which leads to segmentation faults
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as new features, bug fixes, or other behavior changes. Documentation-only updates are not considered user-facing changes.
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.
-->
Unit tests
### 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-53276][SS] Checking if we own the stamp before closing RocksDB [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #52018:
URL: https://github.com/apache/spark/pull/52018#discussion_r2277084277
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreProvider.scala:
##########
@@ -767,7 +767,9 @@ private[sql] class RocksDBStateStoreProvider
}
override def close(): Unit = {
- rocksDB.close()
+ if (stateMachine.close()) {
+ rocksDB.close()
+ }
Review Comment:
Is this logic correct? Technically, this new change means there is no way to close the underlying `rocksDB` from the upper layer,`RocksDBStateStoreProvider` side.
May I ask why we cannot do like the following if there is a case `stateMachine.close() == false`?
```scala
stateMachine.close()
rocksDB.close()
```
--
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-53276][SS] Checking if we own the stamp before closing RocksDB [spark]
Posted by "ericm-db (via GitHub)" <gi...@apache.org>.
ericm-db commented on code in PR #52018:
URL: https://github.com/apache/spark/pull/52018#discussion_r2277110853
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreLockHardeningSuite.scala:
##########
@@ -620,6 +620,175 @@ class RocksDBStateStoreLockHardeningSuite extends SparkFunSuite
}
}
+ test("lock hardening: safe provider close during concurrent commit operations") {
Review Comment:
Thanks for the catch - fixed
--
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-53276][SS] Checking if we own the stamp before closing RocksDB [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun closed pull request #52018: [SPARK-53276][SS] Checking if we own the stamp before closing RocksDB
URL: https://github.com/apache/spark/pull/52018
--
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-53276][SS] Checking if we own the stamp before closing RocksDB [spark]
Posted by "ericm-db (via GitHub)" <gi...@apache.org>.
ericm-db commented on PR #52018:
URL: https://github.com/apache/spark/pull/52018#issuecomment-3187739984
The failing tests pass locally, but I'm not able to merge back from 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
Re: [PR] [SPARK-53276][SS] Checking if we own the stamp before closing RocksDB [spark]
Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on PR #52018:
URL: https://github.com/apache/spark/pull/52018#issuecomment-3190432834
Thank you @ericm-db ~
--
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-53276][SS] Checking if we own the stamp before closing RocksDB [spark]
Posted by "ericm-db (via GitHub)" <gi...@apache.org>.
ericm-db commented on PR #52018:
URL: https://github.com/apache/spark/pull/52018#issuecomment-3185980551
cc @LuciferYang this is the issue that was causing the crash and timeout.
--
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-53276][SS] Checking if we own the stamp before closing RocksDB [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #52018:
URL: https://github.com/apache/spark/pull/52018#issuecomment-3189808365
Merged to master.
BTW, @ericm-db and @anishshri-db . `branch-4.0` has the same symptoms in these days which means RocksDB JVM crashes.
- https://github.com/apache/spark/actions/runs/16956317918/job/48106068290
Do you think we can have a similar investigation and mitigation on `branch-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-53276][SS] Checking if we own the stamp before closing RocksDB [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on PR #52018:
URL: https://github.com/apache/spark/pull/52018#issuecomment-3185896137
+1 - thanks for fixing 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-53276][SS] Checking if we own the stamp before closing RocksDB [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #52018:
URL: https://github.com/apache/spark/pull/52018#discussion_r2277089862
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreLockHardeningSuite.scala:
##########
@@ -620,6 +620,175 @@ class RocksDBStateStoreLockHardeningSuite extends SparkFunSuite
}
}
+ test("lock hardening: safe provider close during concurrent commit operations") {
Review Comment:
According to the following Apache Spark guideline, please consider to use a test case prefix for the bug fix test case, @ericm-db and @anishshri-db . IIRC, this was suggested from Databricks . 😄
> Also, you should consider writing a JIRA ID in the tests when your pull request targets to fix a specific issue.
https://spark.apache.org/contributing.html
--
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-53276][SS] Checking if we own the stamp before closing RocksDB [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #52018:
URL: https://github.com/apache/spark/pull/52018#discussion_r2277101017
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreProvider.scala:
##########
@@ -767,7 +767,9 @@ private[sql] class RocksDBStateStoreProvider
}
override def close(): Unit = {
- rocksDB.close()
+ if (stateMachine.close()) {
+ rocksDB.close()
+ }
Review Comment:
Got it.
--
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-53276][SS] Checking if we own the stamp before closing RocksDB [spark]
Posted by "ericm-db (via GitHub)" <gi...@apache.org>.
ericm-db commented on code in PR #52018:
URL: https://github.com/apache/spark/pull/52018#discussion_r2277089669
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreProvider.scala:
##########
@@ -767,7 +767,9 @@ private[sql] class RocksDBStateStoreProvider
}
override def close(): Unit = {
- rocksDB.close()
+ if (stateMachine.close()) {
+ rocksDB.close()
+ }
Review Comment:
Good question. Basically stateMachine.close() returns a Boolean of whether we've already closed this instance or not. Having this check keeps us from double closing.
--
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-53276][SS] Checking if we own the stamp before closing RocksDB [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #52018:
URL: https://github.com/apache/spark/pull/52018#issuecomment-3189836421
Thank you so much!
--
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-53276][SS] Checking if we own the stamp before closing RocksDB [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #52018:
URL: https://github.com/apache/spark/pull/52018#discussion_r2277089862
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreLockHardeningSuite.scala:
##########
@@ -620,6 +620,175 @@ class RocksDBStateStoreLockHardeningSuite extends SparkFunSuite
}
}
+ test("lock hardening: safe provider close during concurrent commit operations") {
Review Comment:
According to the following Apache Spark guideline, please consider to use a test case prefix for the bug fix test case, @ericm-db and @anishshri-db . IIRC, this is suggested from Databricks . 😄
> Also, you should consider writing a JIRA ID in the tests when your pull request targets to fix a specific issue. I
https://spark.apache.org/contributing.html
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreLockHardeningSuite.scala:
##########
@@ -620,6 +620,175 @@ class RocksDBStateStoreLockHardeningSuite extends SparkFunSuite
}
}
+ test("lock hardening: safe provider close during concurrent commit operations") {
Review Comment:
According to the following Apache Spark guideline, please consider to use a test case prefix for the bug fix test case, @ericm-db and @anishshri-db . IIRC, this is suggested from Databricks . 😄
> Also, you should consider writing a JIRA ID in the tests when your pull request targets to fix a specific issue.
https://spark.apache.org/contributing.html
--
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-53276][SS] Checking if we own the stamp before closing RocksDB [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #52018:
URL: https://github.com/apache/spark/pull/52018#issuecomment-3189318530
FYI, we can ignore `connect` and `pipeline` module CI because they are known flaky tests like RocksDB test in these days.
If this fix stabilizes RocksDB part, it would be great. Thank you!
--
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-53276][SS] Checking if we own the stamp before closing RocksDB [spark]
Posted by "anishshri-db (via GitHub)" <gi...@apache.org>.
anishshri-db commented on PR #52018:
URL: https://github.com/apache/spark/pull/52018#issuecomment-3189816880
@dongjoon-hyun - yea sure - I ll take a look for the 4.0 branch as well
--
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-53276][SS] Checking if we own the stamp before closing RocksDB [spark]
Posted by "ericm-db (via GitHub)" <gi...@apache.org>.
ericm-db commented on code in PR #52018:
URL: https://github.com/apache/spark/pull/52018#discussion_r2277091679
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreProvider.scala:
##########
@@ -767,7 +767,9 @@ private[sql] class RocksDBStateStoreProvider
}
override def close(): Unit = {
- rocksDB.close()
+ if (stateMachine.close()) {
+ rocksDB.close()
+ }
Review Comment:
> Is this logic correct? Technically, this new change means there is no way to close the underlying rocksDB from the upper layer,RocksDBStateStoreProvider side.
This is actually what we intended when we introduced the state machine changes, but I forgot about this method.
--
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-53276][SS] Checking if we own the stamp before closing RocksDB [spark]
Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on PR #52018:
URL: https://github.com/apache/spark/pull/52018#issuecomment-3187079722
also cc @dongjoon-hyun because this pr is attempting to fix the issue of RocksDB crashing.
--
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