Track expired tombstones

Patch by marcuse; reviewed by slebresne for CASSANDRA-7810
This commit is contained in:
Marcus Eriksson 2014-08-26 14:16:48 +02:00
parent 1cf986301b
commit 7f9e9a8718
5 changed files with 38 additions and 3 deletions

View File

@ -1,4 +1,5 @@
1.2.19
* Track expired tombstones (CASSANDRA-7810)
* Validate empty cell names from counter updates (CASSANDRA-7798)
* Improve PasswordAuthenticator default super user setup (CASSANDRA-7788)
* Remove duplicates from StorageService.getJoiningNodes (CASSANDRA-7478)

View File

@ -187,7 +187,7 @@ public class ColumnIndex
// TODO: Should deal with removing unneeded tombstones
if (tombstoneTracker != null)
tombstoneTracker.update(column);
tombstoneTracker.update(column, false);
lastColumn = column;
}

View File

@ -127,6 +127,7 @@ public class RangeTombstone extends Interval<ByteBuffer, DeletionTime> implement
return comparator.compare(t1.max, t2.max);
}
});
public final Set<RangeTombstone> expired = new HashSet<RangeTombstone>();
private int atomCount;
public Tracker(Comparator<ByteBuffer> comparator)
@ -160,6 +161,9 @@ public class RangeTombstone extends Interval<ByteBuffer, DeletionTime> implement
if (comparator.compare(firstColumn.name(), tombstone.max) > 0)
continue;
if (expired.contains(tombstone))
continue;
RangeTombstone updated = new RangeTombstone(firstColumn.name(), tombstone.max, tombstone.data);
Iterator<RangeTombstone> iter = toWrite.iterator();
@ -194,7 +198,7 @@ public class RangeTombstone extends Interval<ByteBuffer, DeletionTime> implement
* If column is a IColumn, check if any tracked range is useless and
* can be removed. If it is a RangeTombstone, add it to this tracker.
*/
public void update(OnDiskAtom atom)
public void update(OnDiskAtom atom, boolean isExpired)
{
if (atom instanceof RangeTombstone)
{
@ -215,6 +219,8 @@ public class RangeTombstone extends Interval<ByteBuffer, DeletionTime> implement
}
ranges.addLast(t);
maxOrderingSet.add(t);
if (isExpired)
expired.add(t);
}
else
{

View File

@ -271,8 +271,9 @@ public class LazilyCompactedRow extends AbstractCompactedRow implements Iterable
RangeTombstone t = tombstone;
tombstone = null;
if (t.data.isGcAble(controller.gcBefore))
if (shouldPurge && t.data.isGcAble(controller.gcBefore))
{
indexBuilder.tombstoneTracker().update(t, true);
return null;
}
else

View File

@ -101,6 +101,33 @@ public class RangeTombstoneTest extends SchemaLoader
assert !isLive(cf, cf.getColumn(b(i))) : "Column " + i + " shouldn't be live";
}
@Test
public void test7810() throws ExecutionException, InterruptedException, IOException
{
DatabaseDescriptor.setInMemoryCompactionLimit(0);
Table table = Table.open(KSNAME);
ColumnFamilyStore cfs = table.getColumnFamilyStore(CFNAME);
cfs.metadata.gcGraceSeconds(2);
String key = "7810";
RowMutation rm;
rm = new RowMutation(KSNAME, ByteBufferUtil.bytes(key));
for (int i = 10; i < 20; i++)
add(rm, i, 0);
rm.apply();
cfs.forceBlockingFlush();
rm = new RowMutation(KSNAME, ByteBufferUtil.bytes(key));
ColumnFamily cf = rm.addOrGet(CFNAME);
cf.delete(new DeletionInfo(b(10),b(11), cfs.getComparator(), 1, 1));
rm.apply();
cfs.forceBlockingFlush();
Thread.sleep(5);
cfs.forceMajorCompaction();
assertEquals(8, Util.getColumnFamily(table, Util.dk(key), CFNAME).getColumnCount());
}
@Test
public void test7808_1() throws ExecutionException, InterruptedException
{