zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From afine <...@git.apache.org>
Subject [GitHub] zookeeper pull request #186: ZOOKEEPER-2711 Avoid synchronization on NettySe...
Date Thu, 09 Mar 2017 23:53:14 GMT
Github user afine commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/186#discussion_r105300714
  
    --- Diff: src/java/main/org/apache/zookeeper/server/NettyServerCnxnFactory.java ---
    @@ -162,7 +162,7 @@ public void messageReceived(ChannelHandlerContext ctx, MessageEvent
e)
                                 + " from " + ctx.getChannel());
                     }
                     NettyServerCnxn cnxn = (NettyServerCnxn)ctx.getAttachment();
    -                synchronized(cnxn) {
    +                synchronized(cnxn.getRpcLock()) {
                         processMessage(e, cnxn);
    --- End diff --
    
    >> Now one thread can be in processMessage while another thread is getting stats
about the connection. Is that ok?
    
    > I believe this is OK. We can receive two concurrent stat commands, but we only process
one of them at a time. I'm also not a Netty wizard, so I could be wildly wrong :)
    
    This should be OK since all fields printed by `synchronized void dumpConnectionInfo(PrintWriter
pwriter, boolean brief)` are only updated in `synchronized` methods.
    
    Another option would be to put a shared lock on the command's execution (shared with any
other 4LW that acquires a lock on a connection other than its own, I THINK `cons` is the only
other one)? I think this may impact 4LW performance slightly but it would prevent the need
to add another lock to `NettyServerCnxn`. 
    
    I think I like your way better.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message