GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Seeing NoSuchElementException in netty ChunkedWriteHandler class · Issue #11046 · netty/netty

Seeing NoSuchElementException in netty ChunkedWriteHandler class #11046

New issue
Copy link
New issue
Copy link
Closed
#11049
Closed
Seeing NoSuchElementException in netty ChunkedWriteHandler class#11046
#11049
Copy link
Milestone
4.1.60.Final

Description

@Arun-LinkedIn
Arun-LinkedIn
opened on Mar 1, 2021
Issue body actions

Hi Netty team,

We are occasionally seeing NoSuchElementException in netty ChunkedWriteHandler.doFlush() method due to remove() being called on empty queue.

java.util.NoSuchElementException:
at java.util.ArrayDeque.removeFirst(ArrayDeque.java:285)
at java.util.ArrayDeque.remove(ArrayDeque.java:452)
at io.netty.handler.stream.ChunkedWriteHandler.doFlush(ChunkedWriteHandler.java:267)
at io.netty.handler.stream.ChunkedWriteHandler.resumeTransfer0(ChunkedWriteHandler.java:119)
at io.netty.handler.stream.ChunkedWriteHandler.access$000(ChunkedWriteHandler.java:68)
at io.netty.handler.stream.ChunkedWriteHandler$1.run(ChunkedWriteHandler.java:111)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384)
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.lang.Thread.run(Thread.java:748)

It seems like the object containing the chunk element (PendingWrite) was found in the queue during peek() at the beginning of doFlush(). But later (few lines below), when it attempts to remove the element (PendingWrite) after writing/flushing the message, it seems like the queue was empty resulting in no such element exception.

Looks like we are seeing this exception after upgrading netty version to 4.1.52.Final (from 4.1.42.Final) which has below change 69cd042.

Netty version

4.1.52.Final

Code using the Netty ChunkedWriteHandler class:
https://github.com/linkedin/ambry/blob/master/ambry-rest/src/main/java/com/github/ambry/rest/NettyResponseChannel.java

Activity

  1. skyguard1 commented on Mar 2, 2021

    @skyguard1
    skyguard1
    on Mar 2, 2021
    Contributor
    More actions

    It seems to be caused by multi-threaded operation of ArrayDeque, it may be that other threads have removed the elements in the queue

  2. normanmaurer commented on Mar 2, 2021

    @normanmaurer
    normanmaurer
    on Mar 2, 2021
    Member
    More actions

    I will have a look..

  3. normanmaurer
    added this to the 4.1.60.Final milestone on Mar 2, 2021
  4. normanmaurer
    added a commit that references this issue on Mar 2, 2021

    Ensure removal from queue happens before writeAndFlush(...) is called

    824e5bf
  5. normanmaurer commented on Mar 2, 2021

    @normanmaurer
    normanmaurer
    on Mar 2, 2021
    Member
    More actions

    Should be fixed by #11049

  6. normanmaurer
    closed this as completedin #11049on Mar 2, 2021
  7. normanmaurer
    added 2 commits that reference this issue on Mar 2, 2021

    Ensure removal from queue happens before writeAndFlush(...) is called (…

    18c66a9

    Ensure removal from queue happens before writeAndFlush(...) is called (…

    bcb165b
  8. raidyue
    added a commit that references this issue on Jul 8, 2022

    Ensure removal from queue happens before writeAndFlush(...) is called (…

    1712288
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      • 4.1.60.Final

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.