Skip to content

CaffeineCache as backingmap can have inconsistent data after eviction #136

Closed
@lyiu18

Description

@lyiu18

Use caffeine as backingmap, saw possible inconsistency after evict entry from cache

The cache setup as following

instead of use it directly as shown in the document, added caffeine inside read-write-backing-map, as I will need to integrate cache-store

<scheme-name>caffeine-distributed-scheme</scheme-name>

<backing-map-scheme>

    <read-write-backing-map-scheme>

      <internal-cache-scheme>

                                            <caffeine-scheme />

                              </internal-cache-scheme>

                              <cachestore-scheme />

                            </read-write-backing-map-scheme>

</backing-map-scheme>

A dummy cacheloader is used, which will throw exception when accessed, this is used for simply show the problem

Insert data into cache normally

evict cache right before issue cache.clear

the evict will eventually call this line

https://github.com/oracle/coherence/blob/main/prj/coherence-core-components/src/main/java/com/tangosol/coherence/component/util/daemon/queueProcessor/service/grid/partitionedService/partitionedCache/Storage.java#L8919

and it seems CaffeineCache will record the eviction but may not synchronously finish the operation

then the cache clear will hit this line

https://github.com/oracle/coherence/blob/main/prj/coherence-core-components/src/main/java/com/tangosol/coherence/component/util/daemon/queueProcessor/service/grid/partitionedService/partitionedCache/Storage.java#L1937

which will return the keys including the key just evicted

code following this will try to remove key one by one, and found the evicted key already gone from cache, then it will try to reload it from cache loader, which will trigger the exception from dummy cache loader

Is this intended behavior? main concern here is if there will be more cases we will see the inconsistency, causing more troubles

Environment (please complete the following information):

  • Coherence 14.1.2.0.1
  • Java 21 zulu
  • OS: linux
  • OS redhat 7
  • Is this a container/cloud environment, no

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions