You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ad...@apache.org on 2017/05/10 10:37:11 UTC
[1/3] cassandra git commit: Fix 2ndary indexes on primary key columns
to don't create expiring entries (CASSANDRA-13412)
Repository: cassandra
Updated Branches:
refs/heads/cassandra-2.1 572fef8a0 -> b0db519b7
refs/heads/cassandra-2.2 6c5ea192c -> 486b82a6b
Fix 2ndary indexes on primary key columns to don't create expiring entries (CASSANDRA-13412)
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b0db519b
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b0db519b
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b0db519b
Branch: refs/heads/cassandra-2.1
Commit: b0db519b79701cecac92a7a2c93101cf17fb928d
Parents: 572fef8
Author: adelapena <a....@gmail.com>
Authored: Fri Apr 21 09:33:16 2017 +0100
Committer: adelapena <a....@gmail.com>
Committed: Wed May 10 10:52:50 2017 +0100
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../AbstractSimplePerColumnSecondaryIndex.java | 2 +-
.../validation/entities/SecondaryIndexTest.java | 42 ++++++++++++++++++++
3 files changed, 44 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/b0db519b/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 2517432..f62f162 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
2.1.18
+ * Fix 2ndary indexes on primary key columns to don't create expiring entries (CASSANDRA-13412)
* Set javac encoding to utf-8 (CASSANDRA-13466)
* Fix 2ndary index queries on partition keys for tables with static columns (CASSANDRA-13147)
* Fix ParseError unhashable type list in cqlsh copy from (CASSANDRA-13364)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/b0db519b/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java b/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
index e80c7bd..d7a1d8a 100644
--- a/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
+++ b/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
@@ -116,7 +116,7 @@ public abstract class AbstractSimplePerColumnSecondaryIndex extends PerColumnSec
DecoratedKey valueKey = getIndexKeyFor(getIndexedValue(rowKey, cell));
ColumnFamily cfi = ArrayBackedSortedColumns.factory.create(indexCfs.metadata, false, 1);
CellName name = makeIndexColumnName(rowKey, cell);
- if (cell instanceof ExpiringCell)
+ if (!columnDef.isPrimaryKeyColumn() && cell instanceof ExpiringCell)
{
ExpiringCell ec = (ExpiringCell) cell;
cfi.addColumn(new BufferExpiringCell(name, ByteBufferUtil.EMPTY_BYTE_BUFFER, ec.timestamp(), ec.getTimeToLive(), ec.getLocalDeletionTime()));
http://git-wip-us.apache.org/repos/asf/cassandra/blob/b0db519b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
index b723f60..1e63e3a 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
@@ -819,4 +819,46 @@ public class SecondaryIndexTest extends CQLTester
assertRows(execute("SELECT * FROM %s WHERE v = ?", 1),
row(1, 1, 9, 1));
}
+
+ @Test
+ public void testIndexOnPartitionKeyInsertExpiringColumn() throws Throwable
+ {
+ createTable("CREATE TABLE %s (k1 int, k2 int, a int, b int, PRIMARY KEY ((k1, k2)))");
+ createIndex("CREATE INDEX on %s(k1)");
+ execute("INSERT INTO %s (k1, k2, a, b) VALUES (1, 2, 3, 4)");
+ assertRows(execute("SELECT * FROM %s WHERE k1 = 1"), row(1, 2, 3, 4));
+ execute("UPDATE %s USING TTL 1 SET b = 10 WHERE k1 = 1 AND k2 = 2");
+ Thread.sleep(1000);
+ assertRows(execute("SELECT * FROM %s WHERE k1 = 1"), row(1, 2, 3, null));
+ }
+
+ @Test
+ public void testIndexOnClusteringKeyInsertExpiringColumn() throws Throwable
+ {
+ createTable("CREATE TABLE %s (pk int, ck int, a int, b int, PRIMARY KEY (pk, ck))");
+ createIndex("CREATE INDEX on %s(ck)");
+ execute("INSERT INTO %s (pk, ck, a, b) VALUES (1, 2, 3, 4)");
+ assertRows(execute("SELECT * FROM %s WHERE ck = 2"), row(1, 2, 3, 4));
+ execute("UPDATE %s USING TTL 1 SET b = 10 WHERE pk = 1 AND ck = 2");
+ Thread.sleep(1000);
+ assertRows(execute("SELECT * FROM %s WHERE ck = 2"), row(1, 2, 3, null));
+ }
+
+ @Test
+ public void testIndexOnRegularColumnInsertExpiringColumn() throws Throwable
+ {
+ createTable("CREATE TABLE %s (pk int, ck int, a int, b int, PRIMARY KEY (pk, ck))");
+ createIndex("CREATE INDEX on %s(a)");
+ execute("INSERT INTO %s (pk, ck, a, b) VALUES (1, 2, 3, 4)");
+ assertRows(execute("SELECT * FROM %s WHERE a = 3"), row(1, 2, 3, 4));
+
+ execute("UPDATE %s USING TTL 1 SET b = 10 WHERE pk = 1 AND ck = 2");
+ Thread.sleep(1000);
+ assertRows(execute("SELECT * FROM %s WHERE a = 3"), row(1, 2, 3, null));
+
+ execute("UPDATE %s USING TTL 1 SET a = 5 WHERE pk = 1 AND ck = 2");
+ Thread.sleep(1000);
+ assertEmpty(execute("SELECT * FROM %s WHERE a = 3"));
+ assertEmpty(execute("SELECT * FROM %s WHERE a = 5"));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
[3/3] cassandra git commit: Merge branch 'cassandra-2.1' into
cassandra-2.2
Posted by ad...@apache.org.
Merge branch 'cassandra-2.1' into cassandra-2.2
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/486b82a6
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/486b82a6
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/486b82a6
Branch: refs/heads/cassandra-2.2
Commit: 486b82a6b056abee533b67662b927d90178c730e
Parents: 6c5ea19 b0db519
Author: adelapena <a....@gmail.com>
Authored: Wed May 10 11:02:40 2017 +0100
Committer: adelapena <a....@gmail.com>
Committed: Wed May 10 11:02:40 2017 +0100
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../AbstractSimplePerColumnSecondaryIndex.java | 2 +-
.../validation/entities/SecondaryIndexTest.java | 42 ++++++++++++++++++++
3 files changed, 44 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/486b82a6/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index bb2e3ba,f62f162..ef2e12c
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,24 -1,5 +1,25 @@@
-2.1.18
+2.2.10
+ * nodetool upgradesstables should upgrade system tables (CASSANDRA-13119)
+ * Avoid starting gossiper in RemoveTest (CASSANDRA-13407)
+ * Fix weightedSize() for row-cache reported by JMX and NodeTool (CASSANDRA-13393)
+ * Fix JVM metric paths (CASSANDRA-13103)
+ * Honor truststore-password parameter in cassandra-stress (CASSANDRA-12773)
+ * Discard in-flight shadow round responses (CASSANDRA-12653)
+ * Don't anti-compact repaired data to avoid inconsistencies (CASSANDRA-13153)
+ * Wrong logger name in AnticompactionTask (CASSANDRA-13343)
+ * Fix queries updating multiple time the same list (CASSANDRA-13130)
+ * Fix GRANT/REVOKE when keyspace isn't specified (CASSANDRA-13053)
+ * Avoid race on receiver by starting streaming sender thread after sending init message (CASSANDRA-12886)
+ * Fix "multiple versions of ant detected..." when running ant test (CASSANDRA-13232)
+ * Coalescing strategy sleeps too much (CASSANDRA-13090)
+ * Make sure compaction stats are updated when compaction is interrupted (Backport from 3.0, CASSANDRA-12100)
+ * Fix flaky LongLeveledCompactionStrategyTest (CASSANDRA-12202)
+ * Fix failing COPY TO STDOUT (CASSANDRA-12497)
+ * Fix ColumnCounter::countAll behaviour for reverse queries (CASSANDRA-13222)
+ * Exceptions encountered calling getSeeds() breaks OTC thread (CASSANDRA-13018)
+ * Commitlog replay may fail if last mutation is within 4 bytes of end of segment (CASSANDRA-13282)
+Merged from 2.1:
+ * Fix 2ndary indexes on primary key columns to don't create expiring entries (CASSANDRA-13412)
* Set javac encoding to utf-8 (CASSANDRA-13466)
* Fix 2ndary index queries on partition keys for tables with static columns (CASSANDRA-13147)
* Fix ParseError unhashable type list in cqlsh copy from (CASSANDRA-13364)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/486b82a6/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/486b82a6/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
index b653f4e,1e63e3a..e3616f6
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
@@@ -860,109 -820,45 +860,151 @@@ public class SecondaryIndexTest extend
row(1, 1, 9, 1));
}
+ @Test
+ public void testIndexOnPartitionKeyInsertExpiringColumn() throws Throwable
+ {
+ createTable("CREATE TABLE %s (k1 int, k2 int, a int, b int, PRIMARY KEY ((k1, k2)))");
+ createIndex("CREATE INDEX on %s(k1)");
+ execute("INSERT INTO %s (k1, k2, a, b) VALUES (1, 2, 3, 4)");
+ assertRows(execute("SELECT * FROM %s WHERE k1 = 1"), row(1, 2, 3, 4));
+ execute("UPDATE %s USING TTL 1 SET b = 10 WHERE k1 = 1 AND k2 = 2");
+ Thread.sleep(1000);
+ assertRows(execute("SELECT * FROM %s WHERE k1 = 1"), row(1, 2, 3, null));
+ }
+
+ @Test
+ public void testIndexOnClusteringKeyInsertExpiringColumn() throws Throwable
+ {
+ createTable("CREATE TABLE %s (pk int, ck int, a int, b int, PRIMARY KEY (pk, ck))");
+ createIndex("CREATE INDEX on %s(ck)");
+ execute("INSERT INTO %s (pk, ck, a, b) VALUES (1, 2, 3, 4)");
+ assertRows(execute("SELECT * FROM %s WHERE ck = 2"), row(1, 2, 3, 4));
+ execute("UPDATE %s USING TTL 1 SET b = 10 WHERE pk = 1 AND ck = 2");
+ Thread.sleep(1000);
+ assertRows(execute("SELECT * FROM %s WHERE ck = 2"), row(1, 2, 3, null));
+ }
+
+ @Test
+ public void testIndexOnRegularColumnInsertExpiringColumn() throws Throwable
+ {
+ createTable("CREATE TABLE %s (pk int, ck int, a int, b int, PRIMARY KEY (pk, ck))");
+ createIndex("CREATE INDEX on %s(a)");
+ execute("INSERT INTO %s (pk, ck, a, b) VALUES (1, 2, 3, 4)");
+ assertRows(execute("SELECT * FROM %s WHERE a = 3"), row(1, 2, 3, 4));
+
+ execute("UPDATE %s USING TTL 1 SET b = 10 WHERE pk = 1 AND ck = 2");
+ Thread.sleep(1000);
+ assertRows(execute("SELECT * FROM %s WHERE a = 3"), row(1, 2, 3, null));
+
+ execute("UPDATE %s USING TTL 1 SET a = 5 WHERE pk = 1 AND ck = 2");
+ Thread.sleep(1000);
+ assertEmpty(execute("SELECT * FROM %s WHERE a = 3"));
+ assertEmpty(execute("SELECT * FROM %s WHERE a = 5"));
+ }
++
+ /**
+ * Custom index used to test the behavior of the system when the index is not ready.
+ * As Custom indices cannot by <code>PerColumnSecondaryIndex</code> we use a <code>PerRowSecondaryIndex</code>
+ * to avoid the check but return a <code>CompositesSearcher</code>.
+ */
+ public static class IndexBlockingOnInitialization extends PerRowSecondaryIndex
+ {
+ private volatile CountDownLatch latch = new CountDownLatch(1);
+
+ @Override
+ public void index(ByteBuffer rowKey, ColumnFamily cf)
+ {
+ try
+ {
+ latch.await();
+ }
+ catch (InterruptedException e)
+ {
+ Thread.interrupted();
+ }
+ }
+
+ @Override
+ public void delete(DecoratedKey key, Group opGroup)
+ {
+ }
+
+ @Override
+ public void init()
+ {
+ }
+
+ @Override
+ public void reload()
+ {
+ }
+
+ @Override
+ public void validateOptions() throws ConfigurationException
+ {
+ }
+
+ @Override
+ public String getIndexName()
+ {
+ return "testIndex";
+ }
+
+ @Override
+ protected SecondaryIndexSearcher createSecondaryIndexSearcher(Set<ByteBuffer> columns)
+ {
+ return new CompositesSearcher(baseCfs.indexManager, columns)
+ {
+ @Override
+ public boolean canHandleIndexClause(List<IndexExpression> clause)
+ {
+ return true;
+ }
+
+ @Override
+ public void validate(IndexExpression indexExpression) throws InvalidRequestException
+ {
+ }
+ };
+ }
+
+ @Override
+ public void forceBlockingFlush()
+ {
+ }
+
+ @Override
+ public ColumnFamilyStore getIndexCfs()
+ {
+ return baseCfs;
+ }
+
+ @Override
+ public void removeIndex(ByteBuffer columnName)
+ {
+ latch.countDown();
+ }
+
+ @Override
+ public void invalidate()
+ {
+ }
+
+ @Override
+ public void truncateBlocking(long truncatedAt)
+ {
+ }
+
+ @Override
+ public boolean indexes(CellName name)
+ {
+ return false;
+ }
+
+ @Override
+ public long estimateResultRows()
+ {
+ return 0;
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
[2/3] cassandra git commit: Fix 2ndary indexes on primary key columns
to don't create expiring entries (CASSANDRA-13412)
Posted by ad...@apache.org.
Fix 2ndary indexes on primary key columns to don't create expiring entries (CASSANDRA-13412)
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b0db519b
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b0db519b
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b0db519b
Branch: refs/heads/cassandra-2.2
Commit: b0db519b79701cecac92a7a2c93101cf17fb928d
Parents: 572fef8
Author: adelapena <a....@gmail.com>
Authored: Fri Apr 21 09:33:16 2017 +0100
Committer: adelapena <a....@gmail.com>
Committed: Wed May 10 10:52:50 2017 +0100
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../AbstractSimplePerColumnSecondaryIndex.java | 2 +-
.../validation/entities/SecondaryIndexTest.java | 42 ++++++++++++++++++++
3 files changed, 44 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/b0db519b/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 2517432..f62f162 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
2.1.18
+ * Fix 2ndary indexes on primary key columns to don't create expiring entries (CASSANDRA-13412)
* Set javac encoding to utf-8 (CASSANDRA-13466)
* Fix 2ndary index queries on partition keys for tables with static columns (CASSANDRA-13147)
* Fix ParseError unhashable type list in cqlsh copy from (CASSANDRA-13364)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/b0db519b/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java b/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
index e80c7bd..d7a1d8a 100644
--- a/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
+++ b/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
@@ -116,7 +116,7 @@ public abstract class AbstractSimplePerColumnSecondaryIndex extends PerColumnSec
DecoratedKey valueKey = getIndexKeyFor(getIndexedValue(rowKey, cell));
ColumnFamily cfi = ArrayBackedSortedColumns.factory.create(indexCfs.metadata, false, 1);
CellName name = makeIndexColumnName(rowKey, cell);
- if (cell instanceof ExpiringCell)
+ if (!columnDef.isPrimaryKeyColumn() && cell instanceof ExpiringCell)
{
ExpiringCell ec = (ExpiringCell) cell;
cfi.addColumn(new BufferExpiringCell(name, ByteBufferUtil.EMPTY_BYTE_BUFFER, ec.timestamp(), ec.getTimeToLive(), ec.getLocalDeletionTime()));
http://git-wip-us.apache.org/repos/asf/cassandra/blob/b0db519b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
index b723f60..1e63e3a 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
@@ -819,4 +819,46 @@ public class SecondaryIndexTest extends CQLTester
assertRows(execute("SELECT * FROM %s WHERE v = ?", 1),
row(1, 1, 9, 1));
}
+
+ @Test
+ public void testIndexOnPartitionKeyInsertExpiringColumn() throws Throwable
+ {
+ createTable("CREATE TABLE %s (k1 int, k2 int, a int, b int, PRIMARY KEY ((k1, k2)))");
+ createIndex("CREATE INDEX on %s(k1)");
+ execute("INSERT INTO %s (k1, k2, a, b) VALUES (1, 2, 3, 4)");
+ assertRows(execute("SELECT * FROM %s WHERE k1 = 1"), row(1, 2, 3, 4));
+ execute("UPDATE %s USING TTL 1 SET b = 10 WHERE k1 = 1 AND k2 = 2");
+ Thread.sleep(1000);
+ assertRows(execute("SELECT * FROM %s WHERE k1 = 1"), row(1, 2, 3, null));
+ }
+
+ @Test
+ public void testIndexOnClusteringKeyInsertExpiringColumn() throws Throwable
+ {
+ createTable("CREATE TABLE %s (pk int, ck int, a int, b int, PRIMARY KEY (pk, ck))");
+ createIndex("CREATE INDEX on %s(ck)");
+ execute("INSERT INTO %s (pk, ck, a, b) VALUES (1, 2, 3, 4)");
+ assertRows(execute("SELECT * FROM %s WHERE ck = 2"), row(1, 2, 3, 4));
+ execute("UPDATE %s USING TTL 1 SET b = 10 WHERE pk = 1 AND ck = 2");
+ Thread.sleep(1000);
+ assertRows(execute("SELECT * FROM %s WHERE ck = 2"), row(1, 2, 3, null));
+ }
+
+ @Test
+ public void testIndexOnRegularColumnInsertExpiringColumn() throws Throwable
+ {
+ createTable("CREATE TABLE %s (pk int, ck int, a int, b int, PRIMARY KEY (pk, ck))");
+ createIndex("CREATE INDEX on %s(a)");
+ execute("INSERT INTO %s (pk, ck, a, b) VALUES (1, 2, 3, 4)");
+ assertRows(execute("SELECT * FROM %s WHERE a = 3"), row(1, 2, 3, 4));
+
+ execute("UPDATE %s USING TTL 1 SET b = 10 WHERE pk = 1 AND ck = 2");
+ Thread.sleep(1000);
+ assertRows(execute("SELECT * FROM %s WHERE a = 3"), row(1, 2, 3, null));
+
+ execute("UPDATE %s USING TTL 1 SET a = 5 WHERE pk = 1 AND ck = 2");
+ Thread.sleep(1000);
+ assertEmpty(execute("SELECT * FROM %s WHERE a = 3"));
+ assertEmpty(execute("SELECT * FROM %s WHERE a = 5"));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org