Skip to content

Repository information cache map keeps growing until out of memory #3252

Closed
@raestio

Description

@raestio

Hi,

it looks like there is a bug in RepositoryFactorySupport in combination with QuerydslPredicateExecutor causing the repository information cache map to grow indefinitely, which eventually leads to OOM:

Heap usage in version 3.4.3 (same for 3.4.x):
Image

Heap usage in version 3.3.9:
Image

Steps to reproduce and observed behaviour

I'm attaching a sample application below which is based on Spring Data REST, Spring Data JPA and Querydsl:
spring-repository-cache-map-issue.zip

  1. Each HTTP resource request (GET /someItems) will produce a unique entry in repository information cache (repositoryInformationCache)
  2. So the number of entries in the map will be equal to number of executed HTTP requests
  3. The cacheKey is always unique because its compositionHash is calculated from QuerydslJpaPredicateExecutor which doesn't override hashCode method.
    Image

The thing is, it behaves the same in version 3.3.9 as well. But there was:

new ConcurrentReferenceHashMap<>(16, ReferenceType.WEAK)

(changed in #3067 - b21b2e8)
so if I understand correctly, the values were always garbage collected because of the WEAK reference type.

Metadata

Metadata

Assignees

Labels

type: regressionA regression from a previous release

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions