newrelic / newrelic-java-agent

The New Relic Java agent
Apache License 2.0
201 stars 143 forks source link

Memory leak in com.newrelic.instrumentation.lettuce-6.0 #1438

Closed ilya40umov closed 10 months ago

ilya40umov commented 1 year ago

Summary

We recently ran into a memory leak related to NewRelic agent with lettuce instrumentation enabled. Memory leak was very visible by the growing size of the old gen and the number of transaction objects referenced from the NewRelic agent.

Current Workaround

Disabling the lettuce instrumentation fully solved this problem for us:

class_transformer:
  com.newrelic.instrumentation.lettuce-6.0:
    enabled: false

Steps to Reproduce

The problem only manifested in a code path which was calling a repository method with two consecutive calls to the Lettuce client (done via Spring Data wrapper), and before and after this call there are other suspending operations (e.g. db calls). The repository method was similar to the following code:

suspend fun saveData() {
  reactiveRedisOperations.opsForHash().putAndAwait(...)
  reactiveRedisOperations.expire(...).awaitSingle()
}

Your Environment

Kotlin, Spring Boot 2, WebFlux, Coroutines, R2DBC + Lettuce + AWS CDK (e.g. for S3 and SQS/SNS), NewRelic agent (8.2.0).

P.S.

If this is not something that you folks are aware of, I could try building a sample project with a similar stack that would reproduce it.

workato-integration[bot] commented 1 year ago

https://issues.newrelic.com/browse/NR-148025

jtduffy commented 1 year ago

Hi @ilya40umov, Thank you for your report. We are aware of issues around the lettuce instrumentation. If you do have a small repro app that would be fantastic. Thanks again.

ilya40umov commented 1 year ago

So far I have spent a few hours trying to create a sample project with a limited set of code that would reproduce this problem (same set of libs, same version of Spring Boot, same version of NewRelic agent), but with no avail. Looks like I may be missing some critical piece (e.g. some of our custom configurations we have for Redis or DB layer perhaps). Anyway, I may come back to this topic later in the next few weeks in time permits.

jasonjkeller commented 1 year ago

Related: https://issues.newrelic.com/browse/NR-81356