Skip to content

[SPARK-49823][SS] Avoid flush during shutdown in rocksdb close path #48292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

anishshri-db
Copy link
Contributor

What changes were proposed in this pull request?

Avoid flush during shutdown in rocksdb close path

Why are the changes needed?

Without this change, we see sometimes that cancelAllBackgroundWork gets hung if there are memtables that need to be flushed. We also don't need to flush in this path, because we only assume that sync flush is required in the commit path.

	at app//org.rocksdb.RocksDB.cancelAllBackgroundWork(Native Method)
	at app//org.rocksdb.RocksDB.cancelAllBackgroundWork(RocksDB.java:4053)
	at app//org.apache.spark.sql.execution.streaming.state.RocksDB.closeDB(RocksDB.scala:1406)
	at app//org.apache.spark.sql.execution.streaming.state.RocksDB.load(RocksDB.scala:383)

Does this PR introduce any user-facing change?

No

How was this patch tested?

Verified the config is passed manually in the logs and existing unit tests.

Before:

sql/core/target/unit-tests.log:141:18:20:06.223 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 0
sql/core/target/unit-tests.log:776:18:20:06.871 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 0
sql/core/target/unit-tests.log:1096:18:20:07.129 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 0

After:

sql/core/target/unit-tests.log:6561:18:17:42.723 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 1
sql/core/target/unit-tests.log:6947:18:17:43.035 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 1
sql/core/target/unit-tests.log:7344:18:17:43.313 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 1

Was this patch authored or co-authored using generative AI tooling?

No

@anishshri-db anishshri-db changed the title [SPARK-49823] Avoid flush during shutdown in rocksdb close path [SPARK-49823][SS] Avoid flush during shutdown in rocksdb close path Sep 28, 2024
@anishshri-db
Copy link
Contributor Author

cc - @HeartSaVioR @siying - PTAL, thx !

Copy link
Contributor

@siying siying left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@HeartSaVioR HeartSaVioR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@HeartSaVioR
Copy link
Contributor

Thanks! Merging to master.

attilapiros pushed a commit to attilapiros/spark that referenced this pull request Oct 4, 2024
### What changes were proposed in this pull request?
Avoid flush during shutdown in rocksdb close path

### Why are the changes needed?
Without this change, we see sometimes that `cancelAllBackgroundWork` gets hung if there are memtables that need to be flushed. We also don't need to flush in this path, because we only assume that sync flush is required in the commit path.

```
	at app//org.rocksdb.RocksDB.cancelAllBackgroundWork(Native Method)
	at app//org.rocksdb.RocksDB.cancelAllBackgroundWork(RocksDB.java:4053)
	at app//org.apache.spark.sql.execution.streaming.state.RocksDB.closeDB(RocksDB.scala:1406)
	at app//org.apache.spark.sql.execution.streaming.state.RocksDB.load(RocksDB.scala:383)
```

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Verified the config is passed manually in the logs and existing unit tests.

Before:
```
sql/core/target/unit-tests.log:141:18:20:06.223 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 0
sql/core/target/unit-tests.log:776:18:20:06.871 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 0
sql/core/target/unit-tests.log:1096:18:20:07.129 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 0
```

After:
```
sql/core/target/unit-tests.log:6561:18:17:42.723 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 1
sql/core/target/unit-tests.log:6947:18:17:43.035 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 1
sql/core/target/unit-tests.log:7344:18:17:43.313 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 1
```

### Was this patch authored or co-authored using generative AI tooling?
No

Closes apache#48292 from anishshri-db/task/SPARK-49823.

Authored-by: Anish Shrigondekar <anish.shrigondekar@databricks.com>
Signed-off-by: Jungtaek Lim <kabhwan.opensource@gmail.com>
himadripal pushed a commit to himadripal/spark that referenced this pull request Oct 19, 2024
### What changes were proposed in this pull request?
Avoid flush during shutdown in rocksdb close path

### Why are the changes needed?
Without this change, we see sometimes that `cancelAllBackgroundWork` gets hung if there are memtables that need to be flushed. We also don't need to flush in this path, because we only assume that sync flush is required in the commit path.

```
	at app//org.rocksdb.RocksDB.cancelAllBackgroundWork(Native Method)
	at app//org.rocksdb.RocksDB.cancelAllBackgroundWork(RocksDB.java:4053)
	at app//org.apache.spark.sql.execution.streaming.state.RocksDB.closeDB(RocksDB.scala:1406)
	at app//org.apache.spark.sql.execution.streaming.state.RocksDB.load(RocksDB.scala:383)
```

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Verified the config is passed manually in the logs and existing unit tests.

Before:
```
sql/core/target/unit-tests.log:141:18:20:06.223 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 0
sql/core/target/unit-tests.log:776:18:20:06.871 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 0
sql/core/target/unit-tests.log:1096:18:20:07.129 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 0
```

After:
```
sql/core/target/unit-tests.log:6561:18:17:42.723 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 1
sql/core/target/unit-tests.log:6947:18:17:43.035 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 1
sql/core/target/unit-tests.log:7344:18:17:43.313 pool-1-thread-1-ScalaTest-running-RocksDBSuite INFO RocksDB [Thread-17]: [NativeRocksDB-1]             Options.avoid_flush_during_shutdown: 1
```

### Was this patch authored or co-authored using generative AI tooling?
No

Closes apache#48292 from anishshri-db/task/SPARK-49823.

Authored-by: Anish Shrigondekar <anish.shrigondekar@databricks.com>
Signed-off-by: Jungtaek Lim <kabhwan.opensource@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants