[ https://issues.apache.org/jira/browse/CASSANDRA-8281?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14259482#comment-14259482 ]
Benyi Wang edited comment on CASSANDRA-8281 at 12/27/14 8:59 PM: ----------------------------------------------------------------- I believe the root cause of this problem is QueryProcessor, who creates a thread, but never shutdowns it. {code} private static final ScheduledExecutorService evictionCheckTimer=Executors.newScheduledThreadPool(1); {code} This code was introduced in "Fix tests by making QP use its own executor" 488e775cc1 after 2.1.0 and included in 2.1.1. I used cassandra-all-2.1.2.jar from maven central. If you run the above example code with {{Config.setClientMode(true)}} In debug mode in eclipse, you will see the thread created by QueryProcessor keeps running after the program exits main(). {code} package org.apache.cassandra.hadoop.cql3; import org.apache.cassandra.config.Config; import org.apache.cassandra.io.sstable.CQLSSTableWriter; public class TWriter2 { public static void main(String[] args) { String schema = "create table mgindex.test (x int primary key, y int)"; String insert = "insert into mgindex.test (x,y) values(?,?)"; Config.setClientMode(true); CQLSSTableWriter w = CQLSSTableWriter.builder() .inDirectory("/tmp/mgindex/test").forTable(schema) .using(insert).build(); try { w.addRow(1, 1); w.close(); } catch (Exception e) { System.out.println(e); } } } {code} If you run the similar code in a JUnit test, you won't see this problem. I believe the thread is terminated by the test runner. was (Author: bewang.tech): I believe the root cause of this problem is QueryProcessor, who creates a thread, but never shutdowns it. {code} private static final ScheduledExecutorService evictionCheckTimer=Executors.newScheduledThreadPool(1); {code} I used cassandra-all-2.1.2.jar from maven central. If you run the above example code with {{Config.setClientMode(true)}} In debug mode in eclipse, you will see the thread created by QueryProcessor keeps running after the program exits main(). {code} package org.apache.cassandra.hadoop.cql3; import org.apache.cassandra.config.Config; import org.apache.cassandra.io.sstable.CQLSSTableWriter; public class TWriter2 { public static void main(String[] args) { String schema = "create table mgindex.test (x int primary key, y int)"; String insert = "insert into mgindex.test (x,y) values(?,?)"; Config.setClientMode(true); CQLSSTableWriter w = CQLSSTableWriter.builder() .inDirectory("/tmp/mgindex/test").forTable(schema) .using(insert).build(); try { w.addRow(1, 1); w.close(); } catch (Exception e) { System.out.println(e); } } } {code} If you run the similar code in a JUnit test, you won't see this problem. I believe the thread is terminated by the test runner. > CQLSSTableWriter close does not work > ------------------------------------ > > Key: CASSANDRA-8281 > URL: https://issues.apache.org/jira/browse/CASSANDRA-8281 > Project: Cassandra > Issue Type: Bug > Components: API > Environment: Cassandra 2.1.1 > Reporter: Xu Zhongxing > Assignee: Benjamin Lerer > Attachments: CASSANDRA-8281.txt > > > I called CQLSSTableWriter.close(). But the program still cannot exit. But the > same code works fine on Cassandra 2.0.10. > It seems that CQLSSTableWriter cannot be closed, and blocks the program from > exit. -- This message was sent by Atlassian JIRA (v6.3.4#6332)