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
since it caused me too much problems already. |
.../trino-hive/src/test/java/io/trino/plugin/hive/metastore/cache/TestCachingHiveMetastore.java
Outdated
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
Outdated
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
Outdated
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
Outdated
Show resolved
Hide resolved
lib/trino-collect/src/main/java/io/trino/collect/cache/EvictableCache.java
Outdated
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 |
martint
left a comment
There was a problem hiding this comment.
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.
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 |
CachingHiveMetastoreusesHivePartitionNamefor keys in partitioncache.
HivePartitionNamehas 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.getAllwhere 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
HivePartitionNamewithout a name, which is unexpected (andunsupported) in the bulk loading.
Fixes #12513