Merge branch 'cassandra-2.0' into cassandra-2.1

Conflicts:
	CHANGES.txt
	test/unit/org/apache/cassandra/db/RangeTombstoneListTest.java
This commit is contained in:
Sylvain Lebresne 2015-05-29 11:05:02 +02:00
commit e1a67a4f53
3 changed files with 26 additions and 6 deletions

View File

@ -30,6 +30,7 @@
* Fix streaming not holding ref when stream error (CASSANDRA-9295)
* Fix canonical view returning early opened SSTables (CASSANDRA-9396)
Merged from 2.0:
* Fix bad condition in RangeTombstoneList (CASSANDRA-9485)
* Fix potential StackOverflow when setting CrcCheckChance over JMX (CASSANDRA-9488)
* Fix null static columns in pages after the first, paged reversed
queries (CASSANDRA-8502)

View File

@ -146,7 +146,7 @@ public class RangeTombstoneList implements Iterable<RangeTombstone>, IMeasurable
/**
* Adds a new range tombstone.
*
* This method will be faster if the new tombstone sort after all the currently existing ones (this is a common use case),
* This method will be faster if the new tombstone sort after all the currently existing ones (this is a common use case),
* but it doesn't assume it.
*/
public void add(Composite start, Composite end, long markedAt, int delTime)
@ -160,7 +160,7 @@ public class RangeTombstoneList implements Iterable<RangeTombstone>, IMeasurable
int c = comparator.compare(ends[size-1], start);
// Fast path if we add in sorted order
if (c <= 0)
if (c < 0)
{
addInternal(size, start, end, markedAt, delTime);
}

View File

@ -31,7 +31,6 @@ import org.apache.cassandra.utils.ByteBufferUtil;
public class RangeTombstoneListTest
{
private static final Comparator<Composite> cmp = new SimpleDenseCellNameType(IntegerType.instance);
private static final Random rand = new Random();
@Test
public void testDiff()
@ -462,7 +461,23 @@ public class RangeTombstoneListTest
assertEquals(6, l.maxMarkedAt());
}
private RangeTombstoneList makeRandom(int size, int maxItSize, int maxItDistance, int maxMarkedAt)
@Test
public void insertSameTest()
{
// Simple test that adding the same element multiple time ends up
// with that element only a single time (CASSANDRA-9485)
RangeTombstoneList l = new RangeTombstoneList(cmp, 0);
l.add(rt(4, 4, 5, 100));
l.add(rt(4, 4, 6, 110));
l.add(rt(4, 4, 4, 90));
Iterator<RangeTombstone> iter = l.iterator();
assertRT(rt(4, 4, 6, 110), iter.next());
assert !iter.hasNext();
}
private RangeTombstoneList makeRandom(Random rand, int size, int maxItSize, int maxItDistance, int maxMarkedAt)
{
RangeTombstoneList l = new RangeTombstoneList(cmp, size);
@ -495,10 +510,13 @@ public class RangeTombstoneListTest
int MAX_IT_DISTANCE = 10;
int MAX_MARKEDAT = 10;
long seed = System.nanoTime();
Random rand = new Random(seed);
for (int i = 0; i < TEST_COUNT; i++)
{
RangeTombstoneList l1 = makeRandom(rand.nextInt(MAX_LIST_SIZE) + 1, rand.nextInt(MAX_IT_SIZE) + 1, rand.nextInt(MAX_IT_DISTANCE) + 1, rand.nextInt(MAX_MARKEDAT) + 1);
RangeTombstoneList l2 = makeRandom(rand.nextInt(MAX_LIST_SIZE) + 1, rand.nextInt(MAX_IT_SIZE) + 1, rand.nextInt(MAX_IT_DISTANCE) + 1, rand.nextInt(MAX_MARKEDAT) + 1);
RangeTombstoneList l1 = makeRandom(rand, rand.nextInt(MAX_LIST_SIZE) + 1, rand.nextInt(MAX_IT_SIZE) + 1, rand.nextInt(MAX_IT_DISTANCE) + 1, rand.nextInt(MAX_MARKEDAT) + 1);
RangeTombstoneList l2 = makeRandom(rand, rand.nextInt(MAX_LIST_SIZE) + 1, rand.nextInt(MAX_IT_SIZE) + 1, rand.nextInt(MAX_IT_DISTANCE) + 1, rand.nextInt(MAX_MARKEDAT) + 1);
RangeTombstoneList l1Initial = l1.copy();
@ -513,6 +531,7 @@ public class RangeTombstoneListTest
System.out.println("Error merging:");
System.out.println(" l1: " + toString(l1Initial));
System.out.println(" l2: " + toString(l2));
System.out.println("Seed was: " + seed);
throw e;
}
}