-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-30616][SQL] Introduce TTL config option for SQL Metadata Cache #28852
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
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
65e4ebd
[SPARK-30616][SQL] Introduce TTL config option for SQL Metadata Cache
sap1ens ea7bf0f
[SPARK-30616][SQL] Update doc string
sap1ens 28da5cf
[SPARK-30616][SQL] Make a common cache TTL option + add tests
sap1ens 7d94f94
[SPARK-30616][SQL] Addressing code review feedback
sap1ens ec18c33
[SPARK-30616][SQL] Addressing code review feedback
sap1ens 18feeb0
[SPARK-30616][SQL] Addressing code review feedback
sap1ens 1d5248e
[SPARK-30616][SQL] Addressing code review feedback
sap1ens 3e761dc
[SPARK-30616][SQL] Addressing code review feedback
sap1ens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| package org.apache.spark.sql.internal | ||
|
|
||
| import java.util.Locale | ||
| import java.util.concurrent.TimeUnit | ||
|
|
||
| import org.apache.spark.util.Utils | ||
|
|
||
|
|
@@ -226,4 +227,16 @@ object StaticSQLConf { | |
| .version("3.0.0") | ||
| .intConf | ||
| .createWithDefault(100) | ||
|
|
||
| val METADATA_CACHE_TTL_SECONDS = buildStaticConf("spark.sql.metadataCacheTTLSeconds") | ||
| .doc("Time-to-live (TTL) value for the metadata caches: partition file metadata cache and " + | ||
| "session catalog cache. This configuration only has an effect when this value having " + | ||
| "a positive value (> 0). It also requires setting " + | ||
| s"${StaticSQLConf.CATALOG_IMPLEMENTATION} to `hive`, setting " + | ||
| s"${SQLConf.HIVE_FILESOURCE_PARTITION_FILE_CACHE_SIZE} > 0 and setting " + | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you update the message by using ${SQLConf.HIVE_FILESOURCE_PARTITION_FILE_CACHE_SIZE.key} ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was done in #29194 :) |
||
| s"${SQLConf.HIVE_MANAGE_FILESOURCE_PARTITIONS} to `true` " + | ||
| "to be applied to the partition file metadata cache.") | ||
| .version("3.1.0") | ||
| .timeConf(TimeUnit.SECONDS) | ||
| .createWithDefault(-1) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to this PR. I'm wondering how useful is this cache. The file listing is cached in another place(
FileStatusCache), and seems this relation cache doesn't give many benefits. cc @viirya @maropuThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. As you suggested, the most painful part (listed files) has already been cached there. But, it seems some datasources still has somewhat processing costs when resolving a relation (e.g., JDBC datasources send a query to an external database for schema resolution), so I think we need to carefully check performance impacts for removing this cache.
spark/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSourceStrategy.scala
Line 256 in fb51925
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For external data sources, it's common that data are changed outside of Spark. I think it's more important to make sure we get the latest data in a new query. Maybe we should disable this relation cache by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think this cache is still useful for avoiding inferring schema again. This is also an expensive operation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah that's a good point. We should probably investigate how to design the data source API so that sources don't need to infer schema can skip this cache. It's hard to use the JDBC data source as we need to run REFRESH TABLE (or wait for TTL after this PR) once the table is changed outside of spark (which is common to JDBC source).