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

Rest API report netty error on returning large byte[] #17603

Closed
BigFatDog opened this issue Jun 1, 2021 · 1 comment
Closed

Rest API report netty error on returning large byte[] #17603

BigFatDog opened this issue Jun 1, 2021 · 1 comment
Labels
kind/bug Something isn't working

Comments

@BigFatDog
Copy link

Description

My Rest api is simple: to return byte[]:

    @GET
    @Path("{id}")
    @NoCache
    @Produces(MediaType.APPLICATION_OCTET_STREAM)
    public byte[] getPacket(@PathParam("id") Long id) {
            byte[] data =..... // fetch from somewhere
           // byte length is 49193
           return data;
   }

When I run, I got the following error (full error log is in the bottom of this issue):

Caused by: io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1

Expected behavior

Rest API return value without error

My investigation

A solution with spring is to increase the codec memory (https://stackoverflow.com/questions/65248119/debugging-illegalreferencecountexception-refcnt-0-decrement-1):

spring
  codec:
    max-in-memory-size: 10MB

Quarkus Version

1.13.2.Final
Java 8

Full Error Log

2021-06-01 13:56:27,334 INFO [org.apa.zoo.ClientCnxn] (ReadOnlyZKClient-172.16.0.7:2181,172.16.0.14:2181,172.16.0.13:2181@0x0cfacace-EventThread) EventThread shut down for session: 0x2000000b12c1d3a

2021-06-01 13:56:27,426 WARN [io.net.cha.ChannelOutboundBuffer] (vert.x-eventloop-thread-1) Failed to mark a promise as success because it has failed already: DefaultChannelPromise@6db0c3a2(failure: io.netty.handler.codec.EncoderException: io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1), unnotified cause:: io.netty.handler.codec.EncoderException: io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1

at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:104)

at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717)

at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:709)

at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:792)

at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:702)

at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:697)

at io.netty.handler.codec.MessageToMessageEncoder.writePromiseCombiner(MessageToMessageEncoder.java:137)

at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:117)

at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116)

at io.vertx.core.http.impl.HttpChunkContentCompressor.write(HttpChunkContentCompressor.java:38)

at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717)

at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:709)

at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:792)

at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:702)

at io.netty.handler.stream.ChunkedWriteHandler.doFlush(ChunkedWriteHandler.java:300)

at io.netty.handler.stream.ChunkedWriteHandler.flush(ChunkedWriteHandler.java:132)

at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:750)

at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:742)

at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:728)

at io.netty.channel.ChannelDuplexHandler.flush(ChannelDuplexHandler.java:127)

at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:750)

at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:765)

at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:790)

at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:758)

at io.vertx.core.net.impl.ConnectionBase.write(ConnectionBase.java:124)

at io.vertx.core.net.impl.ConnectionBase.lambda$queueForWrite$2(ConnectionBase.java:215)

at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)

at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)

at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)

at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)

at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)

at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)

at java.base/java.lang.Thread.run(Thread.java:829)

Caused by: io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1

at io.netty.util.internal.ReferenceCountUpdater.toLiveRealRefCnt(ReferenceCountUpdater.java:74)

at io.netty.util.internal.ReferenceCountUpdater.release(ReferenceCountUpdater.java:138)

at io.netty.buffer.AbstractReferenceCountedByteBuf.release(AbstractReferenceCountedByteBuf.java:100)

at io.vertx.core.http.impl.AssembledHttpResponse.release(AssembledHttpResponse.java:159)

at io.netty.util.ReferenceCountUtil.release(ReferenceCountUtil.java:88)

at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:91)

... 32 more
@BigFatDog BigFatDog added the kind/bug Something isn't working label Jun 1, 2021
@BigFatDog
Copy link
Author

Duplicate of #14695

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant