Closed chringwer closed 4 months ago
HI @chringwer , thanks for the report. I'm having a little trouble reproducing the issue for testing. Is there any chance you have a quick repro app? Or perhaps a more detailed code example?
I am thinking of something like this:
Flux.<Integer>create(sink -> {})
.map(num -> num * 10)
.timeout(Duration.ofMillis(10L), Mono.empty())
.blockLast();
So, basically whenever you have a Fuseable source which does not emit before being cancelled. In that case the Token will leak.
Thanks @chringwer for the bug report. The fix should be in the next release. (Note: It didn't quite make it into last week's release.)
Description
After upgrading the NR java agent to 8.12.0 we observed much higher GC pressure than before. Investigating some heap dumps revealed an issue with the reactor-netty instrumentation module which seems to not handle cancellations properly in some cases so that tokens are not expired timely.
In particular
FluxMapFuseable_Instrumentation
needs to expire the token when cancelled which is a pretty common scenario for example when doing.flatMap(...).next()
.LambdaSubscriber_Instrumentation
andLambdaMonoSubscriber_Instrumentation
should handledispose()
and expire their tokens accordingly, I guess.For us, patching
FluxMapFuseable_Instrumentation
with acancel()
implementation resolved the memory issues:Expected Behavior
Cancelling an instrumented publisher should not leak any objects
Troubleshooting or NR Diag results
Steps to Reproduce
Your Environment
Java 17, NR agent 8.12.0
Additional context