Skip to content

Commit b8bedf0

Browse files
committed
Persist: Enable reference-cache by default
Default cache TTL is 5 minutes.
1 parent d8df1ea commit b8bedf0

File tree

5 files changed

+34
-23
lines changed

5 files changed

+34
-23
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ as necessary. Empty sections will not end in the release notes.
5656
Furthermore, Sentry integration can also be enabled and configured. And finally, it is now
5757
possible to configure the log level for specific loggers, not just the root logger. The old
5858
`logLevel` field is still supported, but will be removed in a future release.
59+
- If you are not using k8s and you are running Nessie with multiple nodes, you must either
60+
* configure `nessie.version.store.persist.cache-invalidations.service-names`, see
61+
[docs reference](https://projectnessie.org/nessie-latest/configuration/#version-store-advanced-settings),
62+
or
63+
* disable the reference cache by setting `nessie.version.store.persist.reference-cache-ttl` to `PT0S`.
5964

6065
### Changes
6166

@@ -69,6 +74,11 @@ as necessary. Empty sections will not end in the release notes.
6974
* `py-io-impl=pyiceberg.io.fsspec.FsspecFileIO`
7075
* `s3.signer=S3V4RestSigner` when S3 signing is being used
7176
- Iceberg REST: No longer return `*FileIO` options from the Iceberg REST config endpoint
77+
- The reference-cache is now enabled by default with a TTL of 5 minutes for both cached entries
78+
and negative entries. Updated references are invalidated across all Nessie nodes, which works
79+
out of the box in k8s setups. Other multi-node Nessie setups need to configure
80+
`nessie.version.store.persist.cache-invalidations.service-names`, see
81+
[docs reference](https://projectnessie.org/nessie-latest/configuration/#version-store-advanced-settings).
7282

7383
### Fixes
7484

servers/quarkus-common/src/main/java/org/projectnessie/quarkus/providers/storage/PersistProvider.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,14 @@ public CacheBackend produceCacheBackend(
149149
cacheConfig.meterRegistry(meterRegistry.get());
150150
}
151151

152-
Optional<Duration> referenceCacheTtl = storeConfig.referenceCacheTtl();
152+
Duration referenceCacheTtl = storeConfig.referenceCacheTtl();
153153
Optional<Duration> referenceCacheNegativeTtl = storeConfig.referenceCacheNegativeTtl();
154154

155-
if (referenceCacheTtl.isPresent()) {
156-
Duration refTtl = referenceCacheTtl.get();
157-
LOGGER.warn(
158-
"Reference caching is an experimental feature but enabled with a TTL of {}", refTtl);
159-
cacheConfig.referenceTtl(refTtl);
160-
cacheConfig.referenceNegativeTtl(referenceCacheNegativeTtl.orElse(refTtl));
155+
if (referenceCacheTtl
156+
.isPositive()) { // allow disabling the reference-cache by setting the TTL to 0
157+
LOGGER.info("Reference caching is enabled with a TTL of {}", referenceCacheTtl);
158+
cacheConfig.referenceTtl(referenceCacheTtl);
159+
cacheConfig.referenceNegativeTtl(referenceCacheNegativeTtl.orElse(referenceCacheTtl));
161160
}
162161

163162
String info = format("Using objects cache with %d MB", effectiveCacheSizeMB);

servers/quarkus-config/src/main/java/org/projectnessie/quarkus/config/QuarkusStoreConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ public interface QuarkusStoreConfig extends StoreConfig {
150150
OptionalInt cacheCapacityFractionAdjustMB();
151151

152152
@WithName(CONFIG_REFERENCE_CACHE_TTL)
153+
@WithDefault(DEFAULT_REFERENCE_CACHE_TTL)
153154
@Override
154-
Optional<Duration> referenceCacheTtl();
155+
Duration referenceCacheTtl();
155156

156157
@WithName(CONFIG_REFERENCE_NEGATIVE_CACHE_TTL)
157158
@Override

servers/quarkus-server/src/main/resources/application.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ nessie.version.store.type=IN_MEMORY
197197
# Settings this value to 0 disables the fixed size object cache.
198198
# Entirely disabling the cache is not recommended and will negatively affect performance.
199199
#nessie.version.store.persist.cache-capacity-mb=0
200+
#
201+
# Reference cache default TTL is 5 minutes.
202+
nessie.version.store.persist.reference-cache-ttl=PT5M
203+
# negative cache TTL defaults to nessie.version.store.persist.reference-cache-ttl
204+
# nessie.version.store.persist.reference-cache-negative-ttl=PT5M
200205

201206
## Transactional database configuration
202207

versioned/storage/common/src/main/java/org/projectnessie/versioned/storage/common/config/StoreConfig.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public interface StoreConfig {
7070
long DEFAULT_PREVIOUS_HEAD_TIME_SPAN_SECONDS = 5 * 60;
7171

7272
String CONFIG_REFERENCE_CACHE_TTL = "reference-cache-ttl";
73+
String DEFAULT_REFERENCE_CACHE_TTL = "PT5M";
7374

7475
String CONFIG_REFERENCE_NEGATIVE_CACHE_TTL = "reference-cache-negative-ttl";
7576

@@ -258,35 +259,30 @@ default long referencePreviousHeadTimeSpanSeconds() {
258259
}
259260

260261
/**
261-
* Defines the duration how long references shall be kept in the cache. Defaults to not cache
262-
* references. If reference caching is enabled, it is highly recommended to also enable negative
263-
* reference caching.
264-
*
265-
* <p>It is safe to enable this for single node Nessie deployments.
262+
* Defines the duration how long references shall be kept in the cache. Defaults is {@value
263+
* #DEFAULT_REFERENCE_CACHE_TTL}, set to {@code PT0M} to disable. If reference caching is enabled,
264+
* it is highly recommended to also enable negative reference caching.
266265
*
267266
* <p>Recommended value is currently {@code PT5M} for distributed and high values like {@code
268267
* PT1H} for single node Nessie deployments.
269-
*
270-
* <p><em>This feature is experimental except for single Nessie node deployments! If in doubt,
271-
* leave this un-configured!</em>
272268
*/
273-
Optional<Duration> referenceCacheTtl();
269+
@Value.Default
270+
default Duration referenceCacheTtl() {
271+
return Duration.parse(DEFAULT_REFERENCE_CACHE_TTL);
272+
}
274273

275274
/**
276275
* Defines the duration how long sentinels for non-existing references shall be kept in the cache
277276
* (negative reference caching).
278277
*
279278
* <p>Defaults to {@code reference-cache-ttl}. Has no effect, if {@code reference-cache-ttl} is
280-
* not configured. Default is not enabled. If reference caching is enabled, it is highly
281-
* recommended to also enable negative reference caching.
279+
* not a positive value. If reference caching is enabled, it is highly recommended to also enable
280+
* negative reference caching.
282281
*
283282
* <p>It is safe to enable this for single node Nessie deployments.
284283
*
285284
* <p>Recommended value is currently {@code PT5M} for distributed and high values like {@code
286285
* PT1H} for single node Nessie deployments.
287-
*
288-
* <p><em>This feature is experimental except for single Nessie node deployments! If in doubt,
289-
* leave this un-configured!</em>
290286
*/
291287
Optional<Duration> referenceCacheNegativeTtl();
292288

@@ -432,6 +428,6 @@ default Adjustable fromFunction(Function<String, String> configFunction) {
432428
Adjustable withReferenceCacheTtl(Duration referenceCacheTtl);
433429

434430
/** See {@link StoreConfig#referenceCacheNegativeTtl()}. */
435-
Adjustable withReferenceCacheNegativeTtl(Duration referencecacheNegativeTtl);
431+
Adjustable withReferenceCacheNegativeTtl(Duration referenceCacheNegativeTtl);
436432
}
437433
}

0 commit comments

Comments
 (0)