Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom handler for OOM error #2917

Closed
typik89 opened this issue Feb 8, 2022 · 2 comments
Closed

Custom handler for OOM error #2917

typik89 opened this issue Feb 8, 2022 · 2 comments
Labels
for/stackoverflow Questions are best asked on SO or Gitter for/user-attention This issue needs user attention (feedback, rework, etc...) status/invalid We don't feel this issue is valid, or the root cause was found outside of Reactor

Comments

@typik89
Copy link

typik89 commented Feb 8, 2022

How can I handle "java.lang.OutOfMemoryError: Java heap space" in reactor?(https://stackoverflow.com/questions/71016578/how-can-i-handle-java-lang-outofmemoryerror-java-heap-space-in-reactor)

I implemented my simple rest endpoint using reactor and Webflux: https://github.com/typik89/webfluxMemoryRetroProject.
As a result of HTTP GET requests It requests data from a database and creates a file with a size of about 70MB. So If I run it with -xmx100m, I have only an error in logs:
2022-02-07 12:25:06.135 ERROR 10288 --- [actor-tcp-nio-1] r.n.channel.ChannelOperationsHandler : [7edd71ea, L:/127.0.0.1:58918 - R:localhost/127.0.0.1:5432] Error was received while reading the incoming data. The connection will be closed. java.lang.OutOfMemoryError: Java heap space .... 2022-02-07 12:25:06.141 ERROR 10288 --- [actor-tcp-nio-1] i.r.p.client.ReactorNettyClient : Connection Error reactor.netty.ReactorNetty$InternalNettyException: java.lang.OutOfMemoryError: Java heap space
This error isn't handled and an HTTP client request hangs. Is this expected behavior? how can I handle this exception? I've tried onErrorResume and Hooks.onOperatorError but I couldn't intercept this type of exception. It seems unlogical for me that the application keeps working and I can't intercept and handle such errors

@reactorbot reactorbot added the ❓need-triage This issue needs triage, hasn't been looked at by a team member yet label Feb 8, 2022
@simonbasle simonbasle added for/stackoverflow Questions are best asked on SO or Gitter for/user-attention This issue needs user attention (feedback, rework, etc...) status/invalid We don't feel this issue is valid, or the root cause was found outside of Reactor and removed ❓need-triage This issue needs triage, hasn't been looked at by a team member yet labels Feb 8, 2022
@simonbasle
Copy link
Member

as stated in the StackOverflow question comments, once you get an OutOfMemoryError, you're in uncharted territory.
This is a VirtualMachineError, which are described as:

Thrown to indicate that the Java Virtual Machine is broken or has run out of resources necessary for it to continue operating.

Your application is potentially in an unrecoverable state, and the fact that it seem to continue working is not a guarantee that it will continue working.

For that reason, OutOfMemoryError is among the type of exceptions that Reactor doesn't even try to process through the Reactive Streams onError signal. See Exceptions.throwIfJvmFatal.

(marking as invalid/for/stackoverflow because as mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements)

@typik89
Copy link
Author

typik89 commented Feb 8, 2022

@simonbasle , Yes, I totally agree about OOM error and JVM. BUT I see the error in logs and you intercept it. Why I can't customize handling.
Maybe via Hooks class. It's unlogical for me, I would prefer that my application goes down in this case because as you said that it's potentially in an unrecoverable state. But my application keeps working and handling requests in this states and all probes work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for/stackoverflow Questions are best asked on SO or Gitter for/user-attention This issue needs user attention (feedback, rework, etc...) status/invalid We don't feel this issue is valid, or the root cause was found outside of Reactor
Projects
None yet
Development

No branches or pull requests

3 participants