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 — Deadlock can happen when MemoryAwareThreadPoolExecutor with limit is used · Issue #1310 · netty/netty

Deadlock can happen when MemoryAwareThreadPoolExecutor with limit is used #1310

New issue
Copy link
New issue
Copy link
Closed
Closed
Deadlock can happen when MemoryAwareThreadPoolExecutor with limit is used#1310
Copy link
Assignees
normanmaurer
Labels
defect
Milestone
3.6.6.Final

Description

@lhrios
lhrios
opened on Apr 25, 2013
Issue body actions

I believe that I have found a deadlock on Netty 3.6.5.Final. It seems that "New I/O worker #2" thread fires an event while it is holding a lock (AbstractNioWorker.java:343 - channel.writeLock). It waits on a MemoryAwareThreadPoolExecutor$Limiter (because the available space has been exceeded) instance but the "OrderedMemoryAwareThreadPoolExecutor thread #3" can not notify it because "New I/O worker #2" is holding the lock "OrderedMemoryAwareThreadPoolExecutor thread #3" requires to continue processing its requests.

Here are the stack traces:

"New I/O worker #2" prio=6 tid=0x16f1f800 nid=0x9d0 in Object.wait() [0x1758f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:503)
    at org.jboss.netty.handler.execution.MemoryAwareThreadPoolExecutor$Limiter.increase(MemoryAwareThreadPoolExecutor.java:640)
    - locked <0x080da358> (a org.jboss.netty.handler.execution.MemoryAwareThreadPoolExecutor$Limiter)
    at org.jboss.netty.handler.execution.MemoryAwareThreadPoolExecutor.increaseCounter(MemoryAwareThreadPoolExecutor.java:501)
    at org.jboss.netty.handler.execution.MemoryAwareThreadPoolExecutor.execute(MemoryAwareThreadPoolExecutor.java:435)
    at org.jboss.netty.handler.execution.ExecutionHandler.handleUpstream(ExecutionHandler.java:173)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:60)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.channelUnbound(SimpleChannelUpstreamHandler.java:216)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:95)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
    at org.jboss.netty.channel.Channels.fireChannelUnbound(Channels.java:432)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.close(AbstractNioWorker.java:343)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.write0(AbstractNioWorker.java:254)
    - locked <0x08454ce0> (a java.lang.Object)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.writeFromTaskLoop(AbstractNioWorker.java:150)
    at org.jboss.netty.channel.socket.nio.AbstractNioChannel$WriteTask.run(AbstractNioChannel.java:335)
    at org.jboss.netty.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:366)
    at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:290)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:88)
    at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
    at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
    at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
    - <0x080c36d0> (a java.util.concurrent.ThreadPoolExecutor$Worker)

"OrderedMemoryAwareThreadPoolExecutor thread #3" prio=6 tid=0x16ef8800 nid=0x914 waiting for monitor entry [0x17f8e000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.cleanUpWriteBuffer(AbstractNioWorker.java:374)
    - waiting to lock <0x08454ce0> (a java.lang.Object)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.writeFromUserCode(AbstractNioWorker.java:127)
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.handleAcceptedSocket(NioServerSocketPipelineSink.java:99)
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.eventSunk(NioServerSocketPipelineSink.java:36)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendDownstream(DefaultChannelPipeline.java:779)
    at org.jboss.netty.handler.ssl.SslHandler.flushPendingEncryptedWrites(SslHandler.java:1109)
    at org.jboss.netty.handler.ssl.SslHandler.wrap(SslHandler.java:1048)
    at org.jboss.netty.handler.ssl.SslHandler.handleDownstream(SslHandler.java:631)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:591)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendDownstream(DefaultChannelPipeline.java:784)
    at org.jboss.netty.channel.Channels.write(Channels.java:725)
    at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.doEncode(OneToOneEncoder.java:71)
    at org.jboss.netty.handler.codec.oneone.OneToOneStrictEncoder.doEncode(OneToOneStrictEncoder.java:35)
    - locked <0x083e9968> (a org.jboss.netty.channel.socket.nio.NioAcceptedSocketChannel)
    at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:59)
    at org.jboss.netty.handler.codec.compression.JdkZlibEncoder.handleDownstream(JdkZlibEncoder.java:221)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:591)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendDownstream(DefaultChannelPipeline.java:784)
    at org.jboss.netty.handler.execution.ExecutionHandler.handleDownstream(ExecutionHandler.java:186)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:591)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendDownstream(DefaultChannelPipeline.java:784)
    [my project's classes...]
    at org.jboss.netty.channel.SimpleChannelHandler.handleDownstream(SimpleChannelHandler.java:254)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:591)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:582)
    at org.jboss.netty.channel.Channels.write(Channels.java:704)
    at org.jboss.netty.channel.Channels.write(Channels.java:671)
    at org.jboss.netty.channel.AbstractChannel.write(AbstractChannel.java:248)
    [my project's classes...]
    at org.jboss.netty.channel.SimpleChannelHandler.handleDownstream(SimpleChannelHandler.java:254)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:591)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:582)
    at org.jboss.netty.channel.Channels.write(Channels.java:704)
    at org.jboss.netty.channel.Channels.write(Channels.java:671)
    at org.jboss.netty.channel.AbstractChannel.write(AbstractChannel.java:248)
    [my project's classes...]
    - locked <0x083db908> ([my project's classes...])
    [my project's classes...]
    at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:88)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.handler.execution.ChannelUpstreamEventRunnable.doRun(ChannelUpstreamEventRunnable.java:43)
    at org.jboss.netty.handler.execution.ChannelEventRunnable.run(ChannelEventRunnable.java:67)
    at org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor$ChildExecutor.run(OrderedMemoryAwareThreadPoolExecutor.java:314)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
    - <0x083d62a8> (a java.util.concurrent.ThreadPoolExecutor$Worker)
    - <0x0841d6a8> (a java.util.concurrent.locks.ReentrantLock$FairSync)
    - <0x0841e978> (a java.util.concurrent.locks.ReentrantLock$FairSync)
    - <0x0841ea10> (a java.util.concurrent.locks.ReentrantLock$FairSync)

Activity

  1. lhrios commented on May 3, 2013

    @lhrios
    lhrios
    on May 3, 2013
    Author
    More actions

    I am able to reproduce this issue very easily. If necessary I can provide more details.

  2. normanmaurer commented on May 6, 2013

    @normanmaurer
    normanmaurer
    on May 6, 2013
    Member
    More actions

    @lhrios let me have a look today.

  3. ghost assigned
    normanmaurer
    on May 6, 2013
  4. normanmaurer commented on May 6, 2013

    @normanmaurer
    normanmaurer
    on May 6, 2013
    Member
    More actions

    @lhrios a test-case would be awesome :)

  5. normanmaurer
    added a commit that references this issue on May 6, 2013

    [#1310] Fix deadlock which can happen if limit of MemoryAwareThreadPo…

    960067c
  6. normanmaurer commented on May 6, 2013

    @normanmaurer
    normanmaurer
    on May 6, 2013
    Member
    More actions

    @lhrios actual I think I have fixed it... could you please try latest 3.6.6-SNAPSHOT and see if it still happens ?

  7. normanmaurer
    added a commit that references this issue on May 6, 2013

    [#1310] Fix deadlock which can happen if limit of MemoryAwareThreadPo…

    6069501
  8. lhrios commented on May 7, 2013

    @lhrios
    lhrios
    on May 7, 2013
    Author
    More actions

    According to my test-case, the problem has been solved.
    Just in case somebody wants to test too I will describe it (unfortunately I can not send the source-code). It has two parts (I run both on the same machine). The first one simulates clients that send messages to the server on regular intervals. I simulate 25 clients sending messages every 100ms and 100 idle clients (that only receive answers from the server). The server (second part) broadcast every message received to 50 other (random) clients. The issue happens on the server. The constants used depends on the machine that will run the test-case.

  9. normanmaurer commented on May 8, 2013

    @normanmaurer
    normanmaurer
    on May 8, 2013
    Member
    More actions

    nice... Thanks for reporting and verify the fix.

  10. normanmaurer
    closed this as completedon May 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @normanmaurer
    normanmaurer

Labels

defect

Type

No type

Projects

No projects

    Milestone

    • 3.6.6.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.