Author: jbellis
Date: Wed May 25 17:26:16 2011
New Revision: 1127589
URL: http://svn.apache.org/viewvc?rev=1127589&view=rev
Log:
close scrub file handles
patch by jbellis; reviewed by slebresne for CASSANDRA-2669
Modified:
cassandra/branches/cassandra-0.7/CHANGES.txt
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/CompactionManager.java
Modified: cassandra/branches/cassandra-0.7/CHANGES.txt
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1127589&r1=1127588&r2=1127589&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.7/CHANGES.txt Wed May 25 17:26:16 2011
@@ -9,6 +9,7 @@
* add placeholders for missing rows in range query pseudo-RR (CASSANDRA-2680)
* remove no-op HHOM.renameHints (CASSANDRA-2693)
* clone super columns to avoid modifying them during flush (CASSANDRA-2675)
+ * close scrub file handles (CASSANDRA-2669)
0.7.6
Modified:
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/CompactionManager.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/CompactionManager.java?rev=1127589&r1=1127588&r2=1127589&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/CompactionManager.java
(original)
+++
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/CompactionManager.java
Wed May 25 17:26:16 2011
@@ -505,25 +505,29 @@ public class CompactionManager implement
private void doScrub(ColumnFamilyStore cfs) throws IOException
{
assert !cfs.isIndex();
-
for (final SSTableReader sstable : cfs.getSSTables())
- {
- logger.info("Scrubbing " + sstable);
-
- // Calculate the expected compacted filesize
- String compactionFileLocation =
cfs.table.getDataFileLocation(sstable.length());
- if (compactionFileLocation == null)
- throw new IOException("disk full");
- int expectedBloomFilterSize =
Math.max(DatabaseDescriptor.getIndexInterval(),
-
(int)(SSTableReader.getApproximateKeyCount(Arrays.asList(sstable))));
+ scrubOne(cfs, sstable);
+ }
- // loop through each row, deserializing to check for damage.
- // we'll also loop through the index at the same time, using the
position from the index to recover if the
- // row header (key or data size) is corrupt. (This means our
position in the index file will be one row
- // "ahead" of the data file.)
- final BufferedRandomAccessFile dataFile =
BufferedRandomAccessFile.getUncachingReader(sstable.getFilename());
- String indexFilename =
sstable.descriptor.filenameFor(Component.PRIMARY_INDEX);
- BufferedRandomAccessFile indexFile =
BufferedRandomAccessFile.getUncachingReader(indexFilename);
+ private void scrubOne(ColumnFamilyStore cfs, SSTableReader sstable) throws
IOException
+ {
+ logger.info("Scrubbing " + sstable);
+ // Calculate the expected compacted filesize
+ String compactionFileLocation =
cfs.table.getDataFileLocation(sstable.length());
+ if (compactionFileLocation == null)
+ throw new IOException("disk full");
+ int expectedBloomFilterSize =
Math.max(DatabaseDescriptor.getIndexInterval(),
+
(int)(SSTableReader.getApproximateKeyCount(Arrays.asList(sstable))));
+
+ // loop through each row, deserializing to check for damage.
+ // we'll also loop through the index at the same time, using the
position from the index to recover if the
+ // row header (key or data size) is corrupt. (This means our position
in the index file will be one row
+ // "ahead" of the data file.)
+ final BufferedRandomAccessFile dataFile =
BufferedRandomAccessFile.getUncachingReader(sstable.getFilename());
+ String indexFilename =
sstable.descriptor.filenameFor(Component.PRIMARY_INDEX);
+ BufferedRandomAccessFile indexFile =
BufferedRandomAccessFile.getUncachingReader(indexFilename);
+ try
+ {
ByteBuffer nextIndexKey =
ByteBufferUtil.readWithShortLength(indexFile);
{
// throw away variable so we don't have a side effect in the
assert
@@ -662,6 +666,11 @@ public class CompactionManager implement
logger.info("Scrub of " + sstable + " complete; looks like
all " + emptyRows + " rows were tombstoned");
}
}
+ finally
+ {
+ FileUtils.closeQuietly(dataFile);
+ FileUtils.closeQuietly(indexFile);
+ }
}
private void throwIfFatal(Throwable th)