question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple cache invalidation not working with a native build

See original GitHub issue

Describe the bug

Hello, I have a REST endpoint to invalidate all my caches like so:

    @DELETE
    @CacheInvalidateAll(cacheName = Caches.MY_CACHE_A)
    @CacheInvalidateAll(cacheName = Caches.MY_CACHE_B)
    @CacheInvalidateAll(cacheName = Caches.MY_CACHE_C)
    public void invalidateCaches() {
        logger.info("Invalidating declared caches");
    }

When running in dev mode, everything is fine. The DEBUG logs shows that all caches are properly invalidated :

2021-11-03 15:06:12,757 DEBUG [io.qua.cac.run.CacheInvalidateAllInterceptor] (executor-thread-0) Invalidating all entries from cache ["cacheA"]
2021-11-03 15:06:12,759 DEBUG [io.qua.cac.run.CacheInvalidateAllInterceptor] (executor-thread-0) Invalidating all entries from cache ["cacheB"]
2021-11-03 15:06:12,759 DEBUG [io.qua.cac.run.CacheInvalidateAllInterceptor] (executor-thread-0) Invalidating all entries from cache ["cacheC"]

When running in native mode, a bug investigation revealed that only one cache is invalidated. This was reproduced on locahost. Calls to other resources use data from the cache instead of calling the backends. 2021-11-03 15:06:12,759 DEBUG [io.qua.cac.run.CacheInvalidateAllInterceptor] (executor-thread-0) Invalidating all entries from cache ["cacheB"]

(i have changed the cache names above but even after changing the order of the 3 annotations, it was always the same cache that was invalidated)

A temporary workaround is to have my multi-annotated method to delegate the invalidation to as many sub methods as necessary, each one with its own invalidation. Obviously that is the opposite of the interest to have multiple annotations.

(And as a side note, i know this is somewhere on the roadmap: being able to programmatically invalidate all caches from my enum instead of adding/forgetting to add an annotation would even be better)

Thanks for your help ! Pascal.

Expected behavior

All caches mentionned in each annotation are flushed.

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

Linux Sunnyvale 5.4.0-89-generic #100-Ubuntu SMP Fri Sep 24 14:50:10 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version “11.0.12” 2021-07-20

GraalVM version (if different from Java)

OpenJDK Runtime Environment GraalVM CE 21.2.0 (build 11.0.12+6-jvmci-21.2-b08)

Quarkus version or git rev

2.1.4.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 6.8.3

Additional information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
mkoubacommented, Nov 5, 2021

The IllegalArgumentException: duplicate element: @io.quarkus.cache.CacheInvalidateAll() is a regression from 2.4.0.Final. I don’t know yet if the issue comes from Quarkus or a new GraalVM/Mandrel version.

It’s a Quarkus/ArC regression - we somehow overlooked the fact that java.util.Set.of(E...) throws an IAE if there are duplicate elements. I’ll prepare a fix.

1reaction
gwennegcommented, Nov 5, 2021

Not yet, I’ll create one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalidate queries doesn't work [React-Query] - Stack Overflow
The two most common issues why query invalidation is not working are: ... trying to invalidate something that doesn't exist in the cache....
Read more >
Automating Cache Invalidation With Change Data Capture
A common way for doing so is to foresee some admin functionality that allows to clear an application's caches.
Read more >
Cascading Cache Invalidation - Philip Walton
In practice, changes to one of your source files almost always invalidates more than one of your output files—and this happens because you've ......
Read more >
Advanced topics on caching in Apollo Client
This article describes special cases and considerations when using the Apollo Client cache. Bypassing the cache. Sometimes you shouldn't use the cache for...
Read more >
Application Data Caching - Quarkus
The problem is that you have to rely on an external meteorological service ... When a cache key is built from several method...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found