Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-2737

NettyServerCnxFactory leaks connection if exception happens while writing to a channel.

    XMLWordPrintableJSON

Details

    Description

      Found this while debugging occasionally failed unit tests. Currently we do this if exception occurs during writing to a channel with Netty:

      @Override
              public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
                  throws Exception
              {
                  LOG.warn("Exception caught " + e, e.getCause());
                  NettyServerCnxn cnxn = (NettyServerCnxn) ctx.getAttachment();
                  if (cnxn != null) {
                      if (LOG.isDebugEnabled()) {
                          LOG.debug("Closing " + cnxn);
                          cnxn.close();
                      }
                  }
              }
      

      So the connection is only closed when debug mode is enabled. This is problematic as lots of clean up code is abstracted inside the close and without proper close the connection we are leaking resources.

      Commit log indicates the issue exists since day 1 with ZOOKEEPER-733. Note the original patch uploaded to ZOOKEEPER-733 has this close call in right place, and the call gets moved around during iteration of the patches w/o gets noticed.

      Attachments

        Issue Links

          Activity

            People

              hanm Michael Han
              hanm Michael Han
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: