Skip to content

java.lang.OutOfMemoryError: Java heap space occured in api-gateway of the Spring Petclinic Microservice variant #3027

@matthias-huber

Description

@matthias-huber

Describe the bug
I used the Spring Pet Clinic (Microservice variant (commit 8818cc9)) as basis. Added opentelemetry agent 1.2.0 to all microservices (api-gateway, vets-,visits-,customer-service). Traces are exporter to OTel collector. Everything runs with docker-compose. I also changed from internal db to mysql setup. However, I don't think that it is important as the api-gateway doesn't use the database.

I ran a small loadtest with around ~10 req/s and the api-gateway ran out of memory => 2021-05-18 12:58:53.080 WARN 19 --- [or-http-epoll-5] i.n.c.AbstractChannelHandlerContext : An exception 'java.lang.OutOfMemoryError: Java heap space' [enable DEBUG level for full stacktrace] was thrown by a user handler's exceptionCaught() method while handling the following exception:

VisualVM shows the CPU usage of the api-gateway. It shows the typical behaviour of a (memory leak) that less and less memory can be freed after each GC:

api-gateway-cpu

I took a heap dump of the api-gateway after the OutOfMemoryError occured.

Leak Suspect shows:
petclinic_leak_suspect

Histogram shows a lot of io.opentelemetry.javaagent.shaded.instrumentation.reactor.TracingSubscriber Instances

TracingSubscriber

Merge Shortest Path to GC root (with all references) shows the leak suspect "io.opentelemetry.javaagent.bootstrap.instrumentation.context.FieldBackedProvider$ContextStore$io$netty$util$concurrent$GenericFutureListener$io$netty$util$concurrent$GenericFutureListener"

TracingSubscriber_merge_shortest_root_gc

Steps to reproduce
If necessary, I can try to provide a sample or at least the important changes to the repo (-> Slack)

What did you expect to see?
That the api-gateway doesn't ran into the OutOfMemoryError

What did you see instead?
java.lang.OutOfMemoryError: Java heap space

What version are you using?
1.2.0

Environment
Java:
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)

OS:
5.8.0-53-generic #60~20.04.1-Ubuntu

Additional context

Metadata

Metadata

Assignees

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