Skip to content

Commit 6fdc69a

Browse files
authored
Core: Deprecate ContentCache.invalidateAll (apache#10494)
* Deprecate ContentCache.invalidateAll This method does only best-effort invalidation and is susceptible to a race condition. If the caller changed the state that could be cached (perhaps files on the storage) and calls this method, there is no guarantee that the cache will not contain stale entries some time after this method returns. This is a similar problem as the one described at google/guava#1881. `ContentCache` doesn't use a Guava Cache, it uses Caffeine. Caffeine offers partial solution to this issue, but not for `invalidateAll` call. To avoid accidental incorrect use of ContentCache, deprecate the `invalidateAll` method, which can be deceptive for the caller and remove it later. * Document ContentCache.invalidate blocking nature * empty
1 parent 3d9fc1d commit 6fdc69a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/src/main/java/org/apache/iceberg/io/ContentCache.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,23 @@ public InputFile tryCache(InputFile input) {
129129
return input;
130130
}
131131

132+
/**
133+
* Invalidate the cache entry for the given key.
134+
*
135+
* <p>Note: if there is ongoing load, this is a blocking operation, i.e. it will wait for the load
136+
* to complete before invalidating the entry.
137+
*/
132138
public void invalidate(String key) {
133139
cache.invalidate(key);
134140
}
135141

142+
/**
143+
* @deprecated since 1.6.0, will be removed in 1.7.0; This method does only best-effort
144+
* invalidation and is susceptible to a race condition. If the caller changed the state that
145+
* could be cached (perhaps files on the storage) and calls this method, there is no guarantee
146+
* that the cache will not contain stale entries some time after this method returns.
147+
*/
148+
@Deprecated
136149
public void invalidateAll() {
137150
cache.invalidateAll();
138151
}

0 commit comments

Comments
 (0)