You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ty...@apache.org on 2015/01/21 00:49:14 UTC

[1/2] cassandra git commit: Invalidate prepared batch stmts when tables are dropped

Repository: cassandra
Updated Branches:
  refs/heads/trunk 9c6cf3cdf -> b66a547ab


Invalidate prepared batch stmts when tables are dropped

Patch by Edward Ribeiro; reviewed by Tyler Hobbs for CASSANDRA-8652


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/caa4f3d3
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/caa4f3d3
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/caa4f3d3

Branch: refs/heads/trunk
Commit: caa4f3d34aea9016fe66059c39bea378b9ee4373
Parents: e2d140f
Author: Edward Ribeiro <ed...@gmail.com>
Authored: Tue Jan 20 17:47:58 2015 -0600
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Tue Jan 20 17:47:58 2015 -0600

----------------------------------------------------------------------
 CHANGES.txt                                       |  2 ++
 .../org/apache/cassandra/cql3/QueryProcessor.java | 10 ++++++++++
 .../cassandra/cql3/PreparedStatementsTest.java    | 18 +++++++++++++-----
 3 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/caa4f3d3/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 1b14c62..296aa66 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.1.3
+ * Invalidate prepared BATCH statements when related tables
+   or keyspaces are dropped (CASSANDRA-8652)
  * Fix missing results in secondary index queries on collections
    with ALLOW FILTERING (CASSANDRA-8421)
  * Expose EstimatedHistogram metrics for range slices (CASSANDRA-8627)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/caa4f3d3/src/java/org/apache/cassandra/cql3/QueryProcessor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/QueryProcessor.java b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
index 3aee799..e6e6f7d 100644
--- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
@@ -593,6 +593,16 @@ public class QueryProcessor implements QueryHandler
                 statementKsName = selectStatement.keyspace();
                 statementCfName = selectStatement.columnFamily();
             }
+            else if (statement instanceof BatchStatement)
+            {
+                BatchStatement batchStatement = ((BatchStatement) statement);
+                for (ModificationStatement stmt : batchStatement.getStatements())
+                {
+                    if (shouldInvalidate(ksName, cfName, stmt))
+                        return true;
+                }
+                return false;
+            }
             else
             {
                 return false;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/caa4f3d3/test/unit/org/apache/cassandra/cql3/PreparedStatementsTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/PreparedStatementsTest.java b/test/unit/org/apache/cassandra/cql3/PreparedStatementsTest.java
index f65ec18..b5a28df 100644
--- a/test/unit/org/apache/cassandra/cql3/PreparedStatementsTest.java
+++ b/test/unit/org/apache/cassandra/cql3/PreparedStatementsTest.java
@@ -53,14 +53,14 @@ public class PreparedStatementsTest extends SchemaLoader
         // to wait slightly before trying to connect to it. We should fix this but in the meantime using a sleep.
         Thread.sleep(500);
 
-		cluster = Cluster.builder().addContactPoint("127.0.0.1")
+        cluster = Cluster.builder().addContactPoint("127.0.0.1")
                                    .withPort(DatabaseDescriptor.getNativeTransportPort())
                                    .build();
         session = cluster.connect();
 
         session.execute(dropKsStatement);
         session.execute(createKsStatement);
-	}
+    }
 
     @AfterClass
     public static void tearDown() throws Exception
@@ -75,19 +75,27 @@ public class PreparedStatementsTest extends SchemaLoader
         String dropTableStatement = "DROP TABLE IF EXISTS " + KEYSPACE + ".qp_cleanup;";
 
         session.execute(createTableStatement);
+
         PreparedStatement prepared = session.prepare("INSERT INTO " + KEYSPACE + ".qp_cleanup (id, cid, val) VALUES (?, ?, ?)");
+        PreparedStatement preparedBatch = session.prepare("BEGIN BATCH " +
+                                                          "INSERT INTO " + KEYSPACE + ".qp_cleanup (id, cid, val) VALUES (?, ?, ?);" +
+                                                          "APPLY BATCH;");
         session.execute(dropTableStatement);
         session.execute(createTableStatement);
         session.execute(prepared.bind(1, 1, "value"));
+        session.execute(preparedBatch.bind(2, 2, "value2"));
 
         session.execute(dropKsStatement);
         session.execute(createKsStatement);
         session.execute(createTableStatement);
+
+        // The driver will get a response about the prepared statement being invalid, causing it to transparently
+        // re-prepare the statement.  We'll rely on the fact that we get no errors while executing this to show that
+        // the statements have been invalidated.
         session.execute(prepared.bind(1, 1, "value"));
+        session.execute(preparedBatch.bind(2, 2, "value2"));
         session.execute(dropKsStatement);
-
-        // FIXME: where is invalidation actually tested?
-	}
+    }
 
     @Test
     public void testStatementRePreparationOnReconnect()


[2/2] cassandra git commit: Merge branch 'cassandra-2.1' into trunk

Posted by ty...@apache.org.
Merge branch 'cassandra-2.1' into trunk


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b66a547a
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b66a547a
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b66a547a

Branch: refs/heads/trunk
Commit: b66a547abb31e7385e85d3241e2b0dc278403716
Parents: 9c6cf3c caa4f3d
Author: Tyler Hobbs <ty...@datastax.com>
Authored: Tue Jan 20 17:49:04 2015 -0600
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Tue Jan 20 17:49:04 2015 -0600

----------------------------------------------------------------------
 CHANGES.txt                                       |  2 ++
 .../org/apache/cassandra/cql3/QueryProcessor.java | 10 ++++++++++
 .../cassandra/cql3/PreparedStatementsTest.java    | 18 +++++++++++++-----
 3 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b66a547a/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 5e09785,296aa66..b601bb9
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,58 -1,6 +1,60 @@@
 +3.0
 + * Make CassandraException unchecked, extend RuntimeException (CASSANDRA-8560)
 + * Support direct buffer decompression for reads (CASSANDRA-8464)
 + * DirectByteBuffer compatible LZ4 methods (CASSANDRA-7039)
 + * Add role based access control (CASSANDRA-7653)
 + * Group sstables for anticompaction correctly (CASSANDRA-8578)
 + * Add ReadFailureException to native protocol, respond
 +   immediately when replicas encounter errors while handling
 +   a read request (CASSANDRA-7886)
 + * Switch CommitLogSegment from RandomAccessFile to nio (CASSANDRA-8308)
 + * Allow mixing token and partition key restrictions (CASSANDRA-7016)
 + * Support index key/value entries on map collections (CASSANDRA-8473)
 + * Modernize schema tables (CASSANDRA-8261)
 + * Support for user-defined aggregation functions (CASSANDRA-8053)
 + * Fix NPE in SelectStatement with empty IN values (CASSANDRA-8419)
 + * Refactor SelectStatement, return IN results in natural order instead
 +   of IN value list order (CASSANDRA-7981)
 + * Support UDTs, tuples, and collections in user-defined
 +   functions (CASSANDRA-7563)
 + * Fix aggregate fn results on empty selection, result column name,
 +   and cqlsh parsing (CASSANDRA-8229)
 + * Mark sstables as repaired after full repair (CASSANDRA-7586)
 + * Extend Descriptor to include a format value and refactor reader/writer
 +   APIs (CASSANDRA-7443)
 + * Integrate JMH for microbenchmarks (CASSANDRA-8151)
 + * Keep sstable levels when bootstrapping (CASSANDRA-7460)
 + * Add Sigar library and perform basic OS settings check on startup (CASSANDRA-7838)
 + * Support for aggregation functions (CASSANDRA-4914)
 + * Remove cassandra-cli (CASSANDRA-7920)
 + * Accept dollar quoted strings in CQL (CASSANDRA-7769)
 + * Make assassinate a first class command (CASSANDRA-7935)
 + * Support IN clause on any clustering column (CASSANDRA-4762)
 + * Improve compaction logging (CASSANDRA-7818)
 + * Remove YamlFileNetworkTopologySnitch (CASSANDRA-7917)
 + * Do anticompaction in groups (CASSANDRA-6851)
 + * Support user-defined functions (CASSANDRA-7395, 7526, 7562, 7740, 7781, 7929,
 +   7924, 7812, 8063, 7813, 7708)
 + * Permit configurable timestamps with cassandra-stress (CASSANDRA-7416)
 + * Move sstable RandomAccessReader to nio2, which allows using the
 +   FILE_SHARE_DELETE flag on Windows (CASSANDRA-4050)
 + * Remove CQL2 (CASSANDRA-5918)
 + * Add Thrift get_multi_slice call (CASSANDRA-6757)
 + * Optimize fetching multiple cells by name (CASSANDRA-6933)
 + * Allow compilation in java 8 (CASSANDRA-7028)
 + * Make incremental repair default (CASSANDRA-7250)
 + * Enable code coverage thru JaCoCo (CASSANDRA-7226)
 + * Switch external naming of 'column families' to 'tables' (CASSANDRA-4369) 
 + * Shorten SSTable path (CASSANDRA-6962)
 + * Use unsafe mutations for most unit tests (CASSANDRA-6969)
 + * Fix race condition during calculation of pending ranges (CASSANDRA-7390)
 + * Fail on very large batch sizes (CASSANDRA-8011)
 + * Improve concurrency of repair (CASSANDRA-6455, 8208)
 +
 +
  2.1.3
+  * Invalidate prepared BATCH statements when related tables
+    or keyspaces are dropped (CASSANDRA-8652)
   * Fix missing results in secondary index queries on collections
     with ALLOW FILTERING (CASSANDRA-8421)
   * Expose EstimatedHistogram metrics for range slices (CASSANDRA-8627)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b66a547a/src/java/org/apache/cassandra/cql3/QueryProcessor.java
----------------------------------------------------------------------