Skip to content
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

Fix flush_metadata_cache with Glue v2 #22075

Merged
merged 9 commits into from
May 23, 2024
Merged

Fix flush_metadata_cache with Glue v2 #22075

merged 9 commits into from
May 23, 2024

Conversation

findepi
Copy link
Member

@findepi findepi commented May 22, 2024

flush_metadata_cache worked with generic CachingHiveMetastore and
was tested once, orthogonally to selected metastore. Glue v2
implementation has a dedicated own caching implementation, so
flush_metadata_cache has to be updated.

@cla-bot cla-bot bot added the cla-signed label May 22, 2024
@findepi findepi force-pushed the findepi/hive-glue-flush branch from d98206c to a5be3f6 Compare May 22, 2024 15:39
@findepi
Copy link
Member Author

findepi commented May 22, 2024

currently based on #22068

@findepi findepi force-pushed the findepi/hive-glue-flush branch from a5be3f6 to 2a7c816 Compare May 22, 2024 15:40
@github-actions github-actions bot added iceberg Iceberg connector hive Hive connector labels May 22, 2024
@findepi findepi force-pushed the findepi/hive-glue-flush branch 3 times, most recently from 96b14ad to 1b0dd8e Compare May 22, 2024 18:32
@findepi
Copy link
Member Author

findepi commented May 22, 2024

tests failed. problematic test refactor extracted to #22079

Copy link
Member

@dain dain left a comment

Choose a reason for hiding this comment

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

You can merge this as is if you want. We can mess with the glue bindings later, but if you want to do it now, please do 😃

Comment on lines +58 to +61
private enum Global
{
GLOBAL
}
Copy link
Member

Choose a reason for hiding this comment

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

I thought we allowed single line enums when there is one value. Is that not allowed?

Copy link
Member Author

Choose a reason for hiding this comment

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

i can drop this change, if you want. but i want intellij formatter to not change the code, so if it does, we either reformat the code or update the airlift codestyle


@Inject
public FlushMetadataCacheProcedure(Optional<CachingHiveMetastore> cachingHiveMetastore)
public FlushMetadataCacheProcedure(Optional<CachingHiveMetastore> cachingHiveMetastore, Optional<GlueCache> glueCache)
Copy link
Member

Choose a reason for hiding this comment

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

I suggest we add a single interface for this, say MetastoreCacheControl or FlushMetastoreCache or something. Then this code could be generic again.

Copy link
Member Author

Choose a reason for hiding this comment

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

can be. let's do this as a follow-up

CachingHiveMetastore cachingHiveMetastore = this.cachingHiveMetastore
.orElseThrow(() -> new TrinoException(HiveErrorCode.HIVE_METASTORE_ERROR, "Cannot flush, metastore cache is not enabled"));
if (cachingHiveMetastore.isEmpty() && glueCache.isEmpty()) {
// TODO this currently does not work. CachingHiveMetastore is always bound for metastores other than Glue, even when caching is disabled,
Copy link
Member

Choose a reason for hiding this comment

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

Using an optional binder on a "flush" interface may be a way to avoid this problem. We would just need to do bind the interface when shared cache is enabled or glue cache is enabled.

Copy link
Member Author

Choose a reason for hiding this comment

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

i actually don't think we can restore this logic now.
people could become dependent on the fact that they can call flush any time they want. it would be a breaking change.

i didn't want to deal with this within this PR, hence only a TODO added

@@ -17,9 +17,9 @@

import static java.util.Objects.requireNonNull;

record PartitionName(List<String> partitionValues)
public record PartitionName(List<String> partitionValues)
Copy link
Member

Choose a reason for hiding this comment

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

I have been thinking we should add this interface to our general Hive model, and update usages. It just make is so much easier to understand what is going on.

findepi added 9 commits May 23, 2024 09:31
It's generally more expected to ask for information once, so favor
`.add(...)` over `.addCopies(..., 1)`, so that repeated information
retrieval stands out.
Similar to a test we have for Iceberg
(`TestIcebergGlueCatalogAccessOperations`). Hive and Iceberg currently
have different Glue implementations and they also have different
metastore/catalog access patterns, so both need to be tested to prevent
regressions.
Hive tests have packages for thrift, file, glue metastores' tests. Move
the tests from outside into these packages.
1. It's misnamed: it's singular, while the corresponding operation
   operates on multiple partition names (in batches)
2. It's redundant: the actual call counted by getPartitions.
`flush_metadata_cache` worked with generic `CachingHiveMetastore` and
was tested once, orthogonally to selected metastore. Glue v2
implementation has a dedicated own caching implementation, so
`flush_metadata_cache` has to be updated.
@findepi findepi force-pushed the findepi/hive-glue-flush branch from 1b0dd8e to 27cb39d Compare May 23, 2024 07:31
@findepi findepi merged commit 7ccde01 into master May 23, 2024
2 checks passed
@findepi findepi deleted the findepi/hive-glue-flush branch May 23, 2024 07:31
@github-actions github-actions bot added this to the 449 milestone May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed hive Hive connector iceberg Iceberg connector
Development

Successfully merging this pull request may close these issues.

3 participants