This is an automated email from the ASF dual-hosted git repository.
edimitrova pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push:
new 0b60c8f Fix timestamp issue in SinglePartitionSliceCommandTest
testPartitionDeletionRowDeletionTie
0b60c8f is described below
commit 0b60c8f37694d44482768ebc327989f7a42c8c08
Author: Benjamin Lerer <[email protected]>
AuthorDate: Fri Feb 19 18:00:13 2021 +0100
Fix timestamp issue in SinglePartitionSliceCommandTest
testPartitionDeletionRowDeletionTie
Patch by Benjamin Lerer; reviewed by Ekaterina Dimitrova and Berenguer
Blasi for CASSANDRA-16443
---
CHANGES.txt | 1 +
.../org/apache/cassandra/cql3/QueryProcessor.java | 22 +++++++++++++++++++---
.../db/SinglePartitionSliceCommandTest.java | 12 ++++++++++--
3 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index c2abba7..dbfa272 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
4.0-beta5
+ * Fix timestamp issue in SinglePartitionSliceCommandTest
testPartitionD…eletionRowDeletionTie (CASSANDRA-16443)
* Promote protocol V5 out of beta (CASSANDRA-14973)
* Fix incorrect encoding for strings can be UTF8 (CASSANDRA-16429)
* Fix node unable to join when RF > N in multi-DC with added warning
(CASSANDRA-16296)
diff --git a/src/java/org/apache/cassandra/cql3/QueryProcessor.java
b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
index c92718d..87829ab 100644
--- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
@@ -368,9 +368,25 @@ public class QueryProcessor implements QueryHandler
*/
public static UntypedResultSet executeOnceInternal(String query, Object...
values)
{
- CQLStatement statement = parseStatement(query,
internalQueryState().getClientState());
- statement.validate(internalQueryState().getClientState());
- ResultMessage result = statement.executeLocally(internalQueryState(),
makeInternalOptions(statement, values));
+ return executeOnceInternal(internalQueryState(), query, values);
+ }
+
+ /**
+ * Execute an internal query with the provided {@code nowInSec} and {@code
timestamp} for the {@code QueryState}.
+ * <p>This method ensure that the statement will not be cached in the
prepared statement cache.</p>
+ */
+ @VisibleForTesting
+ public static UntypedResultSet executeOnceInternalWithNowAndTimestamp(int
nowInSec, long timestamp, String query, Object... values)
+ {
+ QueryState queryState = new
QueryState(InternalStateInstance.INSTANCE.clientState, timestamp, nowInSec);
+ return executeOnceInternal(queryState, query, values);
+ }
+
+ private static UntypedResultSet executeOnceInternal(QueryState queryState,
String query, Object... values)
+ {
+ CQLStatement statement = parseStatement(query,
queryState.getClientState());
+ statement.validate(queryState.getClientState());
+ ResultMessage result = statement.executeLocally(queryState,
makeInternalOptions(statement, values));
if (result instanceof ResultMessage.Rows)
return
UntypedResultSet.create(((ResultMessage.Rows)result).result);
else
diff --git
a/test/unit/org/apache/cassandra/db/SinglePartitionSliceCommandTest.java
b/test/unit/org/apache/cassandra/db/SinglePartitionSliceCommandTest.java
index 12168ec..102eb90 100644
--- a/test/unit/org/apache/cassandra/db/SinglePartitionSliceCommandTest.java
+++ b/test/unit/org/apache/cassandra/db/SinglePartitionSliceCommandTest.java
@@ -343,10 +343,18 @@ public class SinglePartitionSliceCommandTest
BiFunction<Boolean, Boolean, List<Unfiltered>> tester = (flush,
multiSSTable)->
{
cfs.truncateBlocking();
- QueryProcessor.executeOnceInternal("DELETE FROM
ks.partition_row_deletion USING TIMESTAMP 10 WHERE k=1");
+
+ final long timestamp = FBUtilities.timestampMicros();
+ final int nowInSec = FBUtilities.nowInSeconds();
+
+ QueryProcessor.executeOnceInternalWithNowAndTimestamp(nowInSec,
+ timestamp,
+ "DELETE FROM
ks.partition_row_deletion USING TIMESTAMP 10 WHERE k=1");
if (flush && multiSSTable)
cfs.forceBlockingFlush();
- QueryProcessor.executeOnceInternal("DELETE FROM
ks.partition_row_deletion USING TIMESTAMP 10 WHERE k=1 and c=1");
+ QueryProcessor.executeOnceInternalWithNowAndTimestamp(nowInSec,
+ timestamp,
+ "DELETE FROM
ks.partition_row_deletion USING TIMESTAMP 10 WHERE k=1 and c=1");
if (flush)
cfs.forceBlockingFlush();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]