Fix invalidation race in CachingHiveMetastore#10646
Conversation
The changed caches do not set `cacheBuilder.refreshAfterWrite` (since 3a1bf59), so the `asyncReloading`, which changes `CacheLoader.reload`, and delegates the reset), was redundant.
655fb71 to
a0a9d14
Compare
a0a9d14 to
6d7de31
Compare
Capture more commonalities that before. - `asyncReloading` is used for all caches with `refreshMillis` set - `memoizeMetastore` no longer provide an (unused) Executor - individual cache instantiation is now single line, so all the code reads better - separate bulk-loading cache building from non-bulks loading, since we do not want to do refreshes for bulk-loading caches - remove redundant `cacheBuilder = cacheBuilder.xxx` assignments
6d7de31 to
ec2ffe3
Compare
c96e83f to
b6ebad4
Compare
They have same names as test resources in trino-main. This allows toolkit's and main's test jars to be used together on a plugin's classpath. The chosen prefix, `file-based-system-`, is already used for a few other test resources used in the same test class.
Extract `CacheStatsAssertions` from `TestCachingJdbcClient`.
b6ebad4 to
f3dca68
Compare
|
|
...in-toolkit/src/test/java/io/trino/plugin/base/security/TestFileBasedSystemAccessControl.java
Show resolved
Hide resolved
lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/cache/EvictableLoadingCache.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
I would expect ImmutableBiMap to be less performant, since it tries to create a compacted version at the build() time.
It's a method local state, so immutability doesn't buy me anything
There was a problem hiding this comment.
values.entrySet().stream()...collect()?
There was a problem hiding this comment.
I am implementing a generic-purpose class and i don't know where it's going to be used.
I avoid Streams in this code for performance reasons. We know that Streams are not suitable for every occasion.
There was a problem hiding this comment.
if it is a case then maybe a comment?
There was a problem hiding this comment.
where would you see that?
lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/cache/EvictableLoadingCache.java
Outdated
Show resolved
Hide resolved
lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/cache/EvictableLoadingCache.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
I would prefer a dedicated class. It would be known what is the goal of it. No need to copy paste, no need for SuppressWarnings. Class could have a javadoc etc.
There was a problem hiding this comment.
Just boiler plate. Suppressing something is cheaper that writing a class.
Fix grammar. Improve wording.
d7b33c8 to
3e8f373
Compare
There was a problem hiding this comment.
nit:
List<K> keys = tokenList.stream()
.map(Token::getKey)
.collect(toCollection(ArrayList::new));
kokosing
left a comment
There was a problem hiding this comment.
% I haven't reviewed testLoadAfterInvalidate.
lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/cache/EvictableLoadingCache.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Should we invalidate all entries from dataCache that do not are not mentioned in tokens? So we release stale entries of dataCache in the opportunistic way.
The `LoadingCache` used in `CachingHiveMetastore` was susceptible to a race between load-in-flight and invalidation. The invalidation of a key would not prevent load in flight from being inserted into the cache.
3e8f373 to
0e42ed3
Compare
The
LoadingCacheused inCachingHiveMetastorewas susceptible to a racebetween load-in-flight and invalidation. The invalidation of a key would
not prevent load in flight from being inserted into the cache.
Fixes #10512.