[ https://issues.apache.org/jira/browse/CASSANDRA-9576?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14585907#comment-14585907 ]
Sam Tunnicliffe commented on CASSANDRA-9576: -------------------------------------------- [~philipthompson] I think the problem description is correct, the switching of the connect/execution blocks within {{RangeClient#run}} can cause a connection leak. Pre-8358, upon entering the inner loop, we would assume there to be an existing connection and attempt to use it (on the very first time round the loop, there would be no established connection, hence the comment about the harmless NPE). After executing (providing no errors were encountered), we'd poll for more work then break out of the inner loop, leaving the established connection open and ready to be re-used on the next iteration of the outer loop. Contrarily, the first thing we do now upon entering the inner loop is attempt to open a new connection, whether we need to or not. This would be ok (if inefficient) so long as we ensured that we closed it again after executing the prepared statement. However we don't do that, we just break out of the inner loop without closing the connection. So next time we iterate the outer loop, we'll open another connection (to the same host, as we use a new ListIterator) after entering the inner loop. Finally, {{closeInternal}} only closes the current connection so any others opened during previous iterations will leak. > Connection leak in CQLRecordWriter > ---------------------------------- > > Key: CASSANDRA-9576 > URL: https://issues.apache.org/jira/browse/CASSANDRA-9576 > Project: Cassandra > Issue Type: Bug > Components: Hadoop > Reporter: T Meyarivan > Assignee: Philip Thompson > > Ran into connection leaks when using CQLCassandra > apache-cassandra-2.2.0-beta1-src + CQLOutputFormat (via CqlNativeStorage). > It seems like the order blocks of code starting at > https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java#L298 > were reversed in 2.2 which leads to the connection leaks. -- This message was sent by Atlassian JIRA (v6.3.4#6332)