question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Failed to mark a promise as failure because it has failed already" in logs under heavy load

See original GitHub issue

Hi Team.

Our log monitoring solution found following stack trace in one of our webflux instances.

2022-03-10 07:19:27.393 WARN 1 — [ctor-http-nio-1] i.n.c.AbstractChannelHandlerContext : Failed to mark a promise as failure because it has failed already: DefaultChannelPromise@25c05b40(failure: io.netty.channel.StacklessClosedChannelException), unnotified cause: io.netty.channel.StacklessClosedChannelException at io.netty.channel.AbstractChannel$AbstractUnsafe.write(Object, ChannelPromise)(Unknown Source) io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1 at io.netty.util.internal.ReferenceCountUpdater.toLiveRealRefCnt(ReferenceCountUpdater.java:74) ~[netty-common-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.util.internal.ReferenceCountUpdater.release(ReferenceCountUpdater.java:138) ~[netty-common-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.buffer.AbstractReferenceCountedByteBuf.release(AbstractReferenceCountedByteBuf.java:100) ~[netty-buffer-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.handler.codec.http.DefaultFullHttpResponse.release(DefaultFullHttpResponse.java:116) ~[netty-codec-http-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.util.ReferenceCountUtil.release(ReferenceCountUtil.java:90) ~[netty-common-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.channel.AbstractChannel$AbstractUnsafe.write(AbstractChannel.java:872) ~[netty-transport-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.channel.DefaultChannelPipeline$HeadContext.write(DefaultChannelPipeline.java:1367) ~[netty-transport-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717) ~[netty-transport-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:764) ~[netty-transport-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:790) ~[netty-transport-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:758) ~[netty-transport-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:767) ~[netty-transport-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:790) ~[netty-transport-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:758) ~[netty-transport-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:767) ~[netty-transport-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:790) ~[netty-transport-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:758) ~[netty-transport-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:767) ~[netty-transport-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.channel.AbstractChannelHandlerContext$WriteTask.run(AbstractChannelHandlerContext.java:1071) ~[netty-transport-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) ~[netty-common-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469) ~[netty-common-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:497) ~[netty-transport-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) ~[netty-common-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.70.Final.jar!/:4.1.70.Final] at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.70.Final.jar!/:4.1.70.Final] at java.base/java.lang.Thread.run(Thread.java:829) ~[na:na]

This happened only once under heavy load of performance tests. I couldn’t find any other negative side effect like failed web request or application failure.

I found that underlying ‘StacklessClosedChannelException’ is thrown internally on each healthcheck call (which calls another service to get its status) in our k8s cluster but is never logged anywhere. Under heavy load it leaked out together with warning from ticket description.

image

Netty version

4.1.70.Final

JVM version (e.g. java -version)

Distroless docker jdk image: openjdk version “11.0.14” 2022-01-18 OpenJDK Runtime Environment (build 11.0.14+9-post-Debian-1deb11u1) OpenJDK 64-Bit Server VM (build 11.0.14+9-post-Debian-1deb11u1, mixed mode)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
violetaggcommented, Mar 17, 2022

@pjablonski44 Please open an issue for Spring Cloud Gateway and provide more information for the SCG version, use case etc.

0reactions
pjablonski44commented, Mar 17, 2022

It seems that root cause in my particular case is the downstream service that has broken ssl certificate as I was able to intercept the same exception locally by calling this endpoint from browser with ssl validation. Postman without ssl validation does not cause to throw anything. Probably kubernetes is accepting that ssl issue in liveness/readiness probes but also is causing this exception to be thrown. This particular healthcheck endpoint is served by spring cloud gateway configuration which passes the /api/healthcheck to downstream’s /api/healthcheck over https. It might be webflux issue under heavy load.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Failed to fail the promise because it's done already
I got this problem when I used NioSocketChannel for network programs. I implemented the handlder from ChannelHandler interface, ...
Read more >
Admin Authentication API Errors | Firebase - Google
Here is a full list of the error codes and descriptions, including recommended resolution steps, that are thrown by the Firebase Admin Node.js ......
Read more >
Control flow and error handling - JavaScript - MDN Web Docs
A switch statement allows a program to evaluate an expression and attempt to match the expression's value to a case label. If a...
Read more >
Log files and resolving upgrade errors - Windows Deployment
Learn how to interpret and analyze the log files that are generated during the Windows 10 upgrade process.
Read more >
Promises - Error Handling - Beginner JavaScript - Wes Bos
What does that log "Uncaught (in promise)" mean? It means that there was an error in one of our promises, but we did...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found