Search in sources :

Example 1 with MutableDeletionInfo

use of org.apache.cassandra.db.MutableDeletionInfo in project cassandra by apache.

the class DataResolverTest method testRepairRangeTombstoneWithPartitionDeletion2.

/**
 * Additional test for CASSANDRA-13719: tests the case where a partition deletion doesn't shadow a range tombstone.
 */
@Test
public void testRepairRangeTombstoneWithPartitionDeletion2() {
    EndpointsForRange replicas = makeReplicas(2);
    DataResolver resolver = new DataResolver(command, plan(replicas, ALL), readRepair, nanoTime());
    InetAddressAndPort peer1 = replicas.get(0).endpoint();
    InetAddressAndPort peer2 = replicas.get(1).endpoint();
    // 1st "stream": a partition deletion and a range tombstone
    RangeTombstone rt1 = tombstone("0", true, "9", true, 11, nowInSec);
    PartitionUpdate upd1 = new RowUpdateBuilder(cfm, nowInSec, 1L, dk).addRangeTombstone(rt1).buildUpdate();
    ((MutableDeletionInfo) upd1.deletionInfo()).add(new DeletionTime(10, nowInSec));
    UnfilteredPartitionIterator iter1 = iter(upd1);
    // 2nd "stream": a range tombstone that is covered by the other stream rt
    RangeTombstone rt2 = tombstone("2", true, "3", true, 11, nowInSec);
    RangeTombstone rt3 = tombstone("4", true, "5", true, 10, nowInSec);
    UnfilteredPartitionIterator iter2 = iter(new RowUpdateBuilder(cfm, nowInSec, 1L, dk).addRangeTombstone(rt2).addRangeTombstone(rt3).buildUpdate());
    resolver.preprocess(response(command, peer1, iter1));
    resolver.preprocess(response(command, peer2, iter2));
    // No results, we've only reconciled tombstones.
    try (PartitionIterator data = resolver.resolve()) {
        assertFalse(data.hasNext());
    // 2nd stream should get repaired
    }
    assertEquals(1, readRepair.sent.size());
    Mutation mutation = readRepair.getForEndpoint(peer2);
    assertRepairMetadata(mutation);
    assertRepairContainsNoColumns(mutation);
    // 2nd stream should get both the partition deletion, as well as the part of the 1st stream RT that it misses
    assertRepairContainsDeletions(mutation, new DeletionTime(10, nowInSec), tombstone("0", true, "2", false, 11, nowInSec), tombstone("3", false, "9", true, 11, nowInSec));
}
Also used : MutableDeletionInfo(org.apache.cassandra.db.MutableDeletionInfo) InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) RowUpdateBuilder(org.apache.cassandra.db.RowUpdateBuilder) DeletionTime(org.apache.cassandra.db.DeletionTime) UnfilteredPartitionIterator(org.apache.cassandra.db.partitions.UnfilteredPartitionIterator) PartitionIterator(org.apache.cassandra.db.partitions.PartitionIterator) EndpointsForRange(org.apache.cassandra.locator.EndpointsForRange) UnfilteredPartitionIterator(org.apache.cassandra.db.partitions.UnfilteredPartitionIterator) Mutation(org.apache.cassandra.db.Mutation) RangeTombstone(org.apache.cassandra.db.RangeTombstone) PartitionUpdate(org.apache.cassandra.db.partitions.PartitionUpdate) Test(org.junit.Test)

Aggregations

DeletionTime (org.apache.cassandra.db.DeletionTime)1 MutableDeletionInfo (org.apache.cassandra.db.MutableDeletionInfo)1 Mutation (org.apache.cassandra.db.Mutation)1 RangeTombstone (org.apache.cassandra.db.RangeTombstone)1 RowUpdateBuilder (org.apache.cassandra.db.RowUpdateBuilder)1 PartitionIterator (org.apache.cassandra.db.partitions.PartitionIterator)1 PartitionUpdate (org.apache.cassandra.db.partitions.PartitionUpdate)1 UnfilteredPartitionIterator (org.apache.cassandra.db.partitions.UnfilteredPartitionIterator)1 EndpointsForRange (org.apache.cassandra.locator.EndpointsForRange)1 InetAddressAndPort (org.apache.cassandra.locator.InetAddressAndPort)1 Test (org.junit.Test)1