-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[WIP] feature: Make filesystem cache table aware #27277
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
base: master
Are you sure you want to change the base?
[WIP] feature: Make filesystem cache table aware #27277
Conversation
|
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
|
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
2 similar comments
|
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
|
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
RotRotAl
left a comment
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.
Hi please fix your code (5 test shave failed), and submit signed cla as the bot commented.
| } | ||
|
|
||
| @Config("fs.cache.include-tables") | ||
| @ConfigDescription("List of tables to include in file system cache (schema.table format, supports wildcards like schema.* or *)") |
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.
The wording is a bit off,
| @ConfigDescription("List of tables to include in file system cache (schema.table format, supports wildcards like schema.* or *)") | |
| @ConfigDescription("List of tables to include in file system cache, | |
| use * to cache listings for all tables in all schemas |
|
|
||
| /** | ||
| * Predicate to determine if a table should be cached based on configured include list. | ||
| * Supports wildcards: schema.table, schema.*, or * |
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.
use * to cache listings for all tables in all schemas
lib/trino-filesystem/src/main/java/io/trino/filesystem/cache/CacheFileSystem.java
Show resolved
Hide resolved
|
@RatulDawar have you tried adding this feature to hive connector as well? it will be very helpful |
Yes have already submitted cla 3-4 days back. Also still working on this PR. It's a WIP. |
Sure will add that too in the same PR. |
|
Hi is there something new? |
Hey resolving the comments in fews hours, was waiting for CLA to be signed, it just got signed today. |
1ee85e3 to
6bb2852
Compare
6bb2852 to
5482baf
Compare
5482baf to
feda670
Compare
lib/trino-filesystem-manager/src/main/java/io/trino/filesystem/manager/FileSystemConfig.java
Show resolved
Hide resolved
| if (includeTables.isEmpty()) { | ||
| this.predicate = _ -> true; |
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.
remove.
| return predicate.test(table); | ||
| } | ||
|
|
||
| private static Predicate<SchemaTableName> matches(List<String> tables) |
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.
matches -> buildPredicate
| .map(prefix -> (Predicate<SchemaTableName>) prefix::matches) | ||
| .reduce(Predicate::or) |
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.
Looks fancy, but it would be better to just collect parsed table names on a field
and implement predicate with explicit for loop over them.
also, if any entry is *, then other elements still should be parsed (validated), but don't need to be remembered
| default TrinoFileSystem create(ConnectorSession session, boolean cachingEnabled) | ||
| { | ||
| return create(session); | ||
| } | ||
|
|
||
| default TrinoFileSystem create(ConnectorIdentity identity, boolean cachingEnabled) | ||
| { | ||
| return create(identity); | ||
| } |
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.
i generally like the idea that the FS calling code can knowingly bypass caching layer. Today this is handled by connector's CacheKeyProvider having knowledge of other components internals, eg
Lines 52 to 54 in 99b456a
| if (path.endsWith(".trinoSchema") || path.contains("/.trinoPermissions/")) { | |
| // Needed to avoid caching files from FileHiveMetastore on coordinator during tests | |
| return Optional.empty(); |
trino/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/cache/IcebergCacheKeyProvider.java
Lines 28 to 31 in 2cb497d
| if (path.endsWith(".trinoSchema") || path.contains("/.trinoPermissions/")) { | |
| // Needed to avoid caching files from FileHiveMetastore on coordinator during tests | |
| return Optional.empty(); | |
| } |
I am not sure these new functions are the best way to do it.
at least for FileMetastore i would try to simply inject the uncached underlying FS via Guice, or maybe have it configurable for FileMetastore separately (eg read-only use-cases on static data sets are OK to cache)
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.
if we want to go this direction with new methods in TFSF, please open a separate PR adding those methods.
We can add usage of this methods in FileMetastore (controlled by configuration). This will be a simpler prep change & will ensure we have agreement on the API.
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.
@findepi I think these API's make this bypassing more robust both the Guice binding and api's with caching flag seems better approches than the current cache key provider with context internal file paths.
I would prefer API changes given that it is more flexible for possible future requirements. Open to discussion on this... !
| if (vendedCredentialsEnabled && | ||
| fileIoProperties.containsKey(VENDED_S3_ACCESS_KEY) && | ||
| fileIoProperties.containsKey(VENDED_S3_SECRET_KEY) && | ||
| fileIoProperties.containsKey(VENDED_S3_SESSION_TOKEN)) { | ||
| // Do not include original credentials as they should not be used in vended mode | ||
| ConnectorIdentity identityWithExtraCredentials = ConnectorIdentity.forUser(identity.getUser()) | ||
| .withGroups(identity.getGroups()) | ||
| .withPrincipal(identity.getPrincipal()) | ||
| .withEnabledSystemRoles(identity.getEnabledSystemRoles()) | ||
| .withConnectorRole(identity.getConnectorRole()) | ||
| .withExtraCredentials(ImmutableMap.<String, String>builder() | ||
| .put(EXTRA_CREDENTIALS_ACCESS_KEY_PROPERTY, fileIoProperties.get(VENDED_S3_ACCESS_KEY)) | ||
| .put(EXTRA_CREDENTIALS_SECRET_KEY_PROPERTY, fileIoProperties.get(VENDED_S3_SECRET_KEY)) | ||
| .put(EXTRA_CREDENTIALS_SESSION_TOKEN_PROPERTY, fileIoProperties.get(VENDED_S3_SESSION_TOKEN)) | ||
| .buildOrThrow()) | ||
| .build(); |
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.
That looks like a copy of the method above. Avoid copying (duplicating) this logic.
| * @param cachingEnabled whether file system caching should be enabled | ||
| * @return a TrinoFileSystem instance | ||
| */ | ||
| default TrinoFileSystem create(ConnectorSession session, Map<String, String> fileIoProperties, boolean cachingEnabled) |
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.
the problem is that cachingEnabled = true does not imply there will be any caching
it depends what the backing TrinoFileSystemFactory is. i.e. caching needs to be allowed on the FS layer as well
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.
Seems fair, I think then it's make it virtually impossible to use apis with caching flags.
Should we go guice dependencies ? That seems fine over handling this in cachekeyprovider.
| private final Predicate<SchemaTableName> predicate; | ||
|
|
||
| @Inject | ||
| public TableCachingPredicate(FileSystemConfig config) |
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.
This looks like part of trino-filesystem-manager caching layer, but it's used only in Iceberg.
For FS caching it would be more natural to cache based on locations, but i can see how user-unfriendly this might be and that cache control by table names is reasonable.
This currently is a connector-specific cache control and if implemented as such, it should be configured as such. see delta.fs.cache.disable-transaction-log-caching for example of pre-existing connector-specific cache control.
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.
@findepi I think we can extended it for all importers of trino-file-system manager as this doesn't require any connector specific handling. Adding this specific to connectos seems to add more complexity than implementing it connector agonistic.
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.
Let me confirm if this is possible or not
- Change default value from empty list to ImmutableList.of('*') to maintain backward compatibility
- Add @notempty validation to reject empty list configuration
- Add test to verify empty list validation fails
- Add jakarta.validation-api and io.airlift:testing dependencies to pom.xml
…itialization and improve readability
|
This pull request has gone a while without any activity. Ask for help on #core-dev on Trino slack. |
|
Closing this pull request, as it has been stale for six weeks. Feel free to re-open at any time. |
|
@RatulDawar any update? |
I have addressed all the comments need to start a discussion on how the API's should be formed here, will add my pointers and do that in this week itself, will again start working on this actively |
Related Issue : #27276