-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 CachingHiveMetastore.getPartitionsByNames failing while cache invalidation #12439
Fix CachingHiveMetastore.getPartitionsByNames failing while cache invalidation #12439
Conversation
This is just a test at this moment, not a solution. My favorite solution would be to kill this hack trino/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/HivePartitionName.java Line 35 in 03d8e5a
since it caused me too much problems already. |
.../trino-hive/src/test/java/io/trino/plugin/hive/metastore/cache/TestCachingHiveMetastore.java
Show resolved
Hide resolved
cf16f5d
to
0176528
Compare
lib/trino-collect/src/test/java/io/trino/collect/cache/TestEvictableLoadingCache.java
Outdated
Show resolved
Hide resolved
b1b8f23
to
d6c42e0
Compare
@findepi can you attach to the description of the PR a series of SQL statements that reproduce the scenario? |
lib/trino-collect/src/main/java/io/trino/collect/cache/EvictableCache.java
Outdated
Show resolved
Hide resolved
No. It cannot be observed in sequential process, unless there is a very specific timing. |
lib/trino-collect/src/test/java/io/trino/collect/cache/TestEvictableLoadingCache.java
Show resolved
Hide resolved
lib/trino-collect/src/main/java/io/trino/collect/cache/EvictableCache.java
Outdated
Show resolved
Hide resolved
lib/trino-collect/src/main/java/io/trino/collect/cache/EvictableCache.java
Show resolved
Hide resolved
lib/trino-collect/src/main/java/io/trino/collect/cache/EvictableCache.java
Outdated
Show resolved
Hide resolved
lib/trino-collect/src/main/java/io/trino/collect/cache/EvictableCache.java
Show resolved
Hide resolved
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.
LGTM (just skimmed tests)
lib/trino-collect/src/main/java/io/trino/collect/cache/EvictableCache.java
Show resolved
Hide resolved
c285a97
to
44209e1
Compare
AC |
The change broke load sharing for concurrent single-value loads. Will fix address that. |
…alidation `CachingHiveMetastore` uses `HivePartitionName` for keys in partition cache. `HivePartitionName` has a peculiar, semi- value-based equality. HivePartitionName may or may not be missing a name and it matters for bulk load, but it doesn't matter for a single-partition load. Because of equality semantics, the cache keys may gets mixed during bulk load. This happens within `EvictableCache.getAll` where we compute tokens. We may get an existing token and normally it's fine, since existing entry is satisfied without a bulk load. However, if existing token has no data in the `EvictableCache.dataCache` (e.g. due to explicit or implicit invalidation), the loading gets invoked. Thus, a bulk loading may get a `HivePartitionName` without a name, which is unexpected (and unsupported) in the bulk loading.
df7b4cd
to
4a31b9e
Compare
Added a test and retracted change in |
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.
Thanks for the detailed explanation of the problem in the commit message. Would you mind describing, at a high level, the approach to fixing it?
* the test exists primarily to document current state and support discussion, should the current state change. | ||
*/ | ||
@Test(timeOut = TEST_TIMEOUT_MILLIS) | ||
public void testConcurrentGetWithCallableShareLoad() |
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.
We should look into jcstress (https://github.com/openjdk/jcstress) for testing concurrency (for later, not as part of this PR).
Well, the fix is the inverse of the problem -- pass the keys provided to |
CachingHiveMetastore
usesHivePartitionName
for keys in partitioncache.
HivePartitionName
has a peculiar, semi- value-based equality.HivePartitionName may or may not be missing a name and it matters for
bulk load, but it doesn't matter for a single-partition load. Because
of equality semantics, the cache keys may gets mixed during bulk load.
This happens within
EvictableCache.getAll
where we compute tokens. Wemay get an existing token and normally it's fine, since existing entry
is satisfied without a bulk load. However, if existing token has no data
in the
EvictableCache.dataCache
(e.g. due to explicit or implicitinvalidation), the loading gets invoked. Thus, a bulk loading may get a
HivePartitionName
without a name, which is unexpected (andunsupported) in the bulk loading.
Fixes #12513