Skip to content

Commit 7a48740

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

File tree

5 files changed

+34
-23
lines changed

5 files changed

+34
-23
lines changed

Diff for: CHANGELOG.md

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

2227
### Breaking changes
2328

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

3949
### Deprecations
4050

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

+6-7
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);

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

+2-1
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

Diff for: servers/quarkus-server/src/main/resources/application.properties

+5
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ nessie.version.store.type=IN_MEMORY
194194
# Settings this value to 0 disables the fixed size object cache.
195195
# Entirely disabling the cache is not recommended and will negatively affect performance.
196196
#nessie.version.store.persist.cache-capacity-mb=0
197+
#
198+
# Reference cache default TTL is 5 minutes.
199+
nessie.version.store.persist.reference-cache-ttl=PT5M
200+
# negative cache TTL defaults to nessie.version.store.persist.reference-cache-ttl
201+
# nessie.version.store.persist.reference-cache-negative-ttl=PT5M
197202

198203
## Transactional database configuration
199204

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

+11-15
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)