cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Freeman (JIRA)" <>
Subject [jira] Created: (CASSANDRA-533) Need to close files in loadBloomFilter and loadIndexFile
Date Sat, 07 Nov 2009 22:30:32 GMT
Need to close files in loadBloomFilter and loadIndexFile

                 Key: CASSANDRA-533
             Project: Cassandra
          Issue Type: Bug
          Components: Core
    Affects Versions: 0.4
         Environment: Vista, Cassandra 0.4.1
            Reporter: Tim Freeman

When starting Cassandra on a Windows system, I intermittently see errors like:

DEBUG - Expected bloom filter size : 2560
DEBUG - collecting Generation:false:4@9
DEBUG - collecting Token:false:16@0
INFO - Saved Token found: 25027551081353517716727338628156823602
ERROR - Error in ThreadPoolExecutor
java.util.concurrent.ExecutionException: Failed to delete LocationInfo-8-Index.db
        at java.util.concurrent.FutureTask$Sync.innerGet(
        at java.util.concurrent.FutureTask.get(
        at org.apache.cassandra.concurrent.DebuggableThreadPoolExecutor.afterExecute(
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(
        at java.util.concurrent.ThreadPoolExecutor$
Caused by: Failed to delete LocationInfo-8-Index.db
        at org.apache.cassandra.utils.FileUtils.deleteWithConfirm(
        at org.apache.cassandra.db.ColumnFamilyStore.doFileCompaction(
        at org.apache.cassandra.db.ColumnFamilyStore.doCompaction(
        at org.apache.cassandra.db.MinorCompactionManager$
        at org.apache.cassandra.db.MinorCompactionManager$
        at java.util.concurrent.FutureTask$Sync.innerRun(
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(
        ... 2 more
DEBUG - Starting to listen on
DEBUG - Binding thrift service to localhost:9160

The problem here is that the files are not closed immediately after they are read, and on
Windows you can't delete an open file.  In general, failing to close a file causes more subtle
problems on a Unix system.  You can run out of file descriptors if files are opened faster
than the garbage collector closes them, and you can run out of disk space if the total data
in the opened-but-deleted files is enough to fill the disk.

I see two places to fix, SSTableReader.loadIndexFile and SSTableReader.loadBloomFilter.  Here
are revised definitions for those two methods:

    private void loadBloomFilter() throws IOException
        DataInputStream stream = new DataInputStream(new FileInputStream(filterFilename()));
        try {
        	bf = BloomFilter.serializer().deserialize(stream);
        } finally {

    private void loadIndexFile() throws IOException
        BufferedRandomAccessFile input = new BufferedRandomAccessFile(indexFilename(), "r");
        try {
        	indexPositions = new ArrayList<KeyPosition>();

        	int i = 0;
        	long indexSize = input.length();
        	while (true)
        		long indexPosition = input.getFilePointer();
        		if (indexPosition == indexSize)
        		String decoratedKey = input.readUTF();
        		if (i++ % INDEX_INTERVAL == 0)
        			indexPositions.add(new KeyPosition(decoratedKey, indexPosition));
        } finally {

I have not yet tested those changes, but they look desirable even if they don't fix the symptom
I'm experiencing.  I did not search the code for other places that files are opened but not

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message