This is an automated email from the ASF dual-hosted git repository.

adelapena pushed a commit to branch cassandra-4.1
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/cassandra-4.1 by this push:
     new 9b4784bdb7 Fix missed nowInSec values in QueryProcessor
9b4784bdb7 is described below

commit 9b4784bdb7d70bf99c9c290d44b053902b00642d
Author: Sathyanarayanan Saravanamuthu <sathya.k...@outlook.com>
AuthorDate: Wed May 11 16:21:19 2022 +0100

    Fix missed nowInSec values in QueryProcessor
    
    patch by Sathyanarayanan Saravanamuthu; reviewed by Andrés de la Peña, 
Benjamin Lerer and Ekaterina Dimitrova for CASSANDRA-17458
    
    Co-authored-by: Sathyanarayanan Saravanamuthu <sathya.k...@outlook.com>
    Co-authored-by: Andrés de la Peña <a.penya.gar...@gmail.com>
---
 CHANGES.txt                                            |  1 +
 src/java/org/apache/cassandra/cql3/QueryProcessor.java | 17 +++++++++--------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 5540de8433..2e7772bf89 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.1-alpha2
+ * Fix missed nowInSec values in QueryProcessor (CASSANDRA-17458)
  * Revert removal of withBufferSizeInMB(int size) in CQLSSTableWriter.Builder 
class and deprecate it in favor of withBufferSizeInMiB(int size) 
(CASSANDRA-17675)
  * Remove expired snapshots of dropped tables after restart (CASSANDRA-17619)
 Merged from 4.0:
diff --git a/src/java/org/apache/cassandra/cql3/QueryProcessor.java 
b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
index e14bfacd1e..f0a0a7425f 100644
--- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
@@ -454,11 +454,11 @@ public class QueryProcessor implements QueryHandler
     public static Future<UntypedResultSet> executeAsync(InetAddressAndPort 
address, String query, Object... values)
     {
         Prepared prepared = prepareInternal(query);
-        QueryOptions options = makeInternalOptions(prepared.statement, values);
+        int nowInSec = FBUtilities.nowInSeconds();
+        QueryOptions options = 
makeInternalOptionsWithNowInSec(prepared.statement, nowInSec, values);
         if (prepared.statement instanceof SelectStatement)
         {
             SelectStatement select = (SelectStatement) prepared.statement;
-            int nowInSec = FBUtilities.nowInSeconds();
             ReadQuery readQuery = select.getQuery(options, nowInSec);
             List<ReadCommand> commands;
             if (readQuery instanceof ReadCommand)
@@ -528,7 +528,7 @@ public class QueryProcessor implements QueryHandler
         try
         {
             Prepared prepared = prepareInternal(query);
-            ResultMessage result = prepared.statement.execute(state, 
makeInternalOptions(prepared.statement, values, cl), nanoTime());
+            ResultMessage result = prepared.statement.execute(state, 
makeInternalOptionsWithNowInSec(prepared.statement, state.getNowInSeconds(), 
values, cl), nanoTime());
             if (result instanceof ResultMessage.Rows)
                 return 
UntypedResultSet.create(((ResultMessage.Rows)result).result);
             else
@@ -547,7 +547,8 @@ public class QueryProcessor implements QueryHandler
             throw new IllegalArgumentException("Only SELECTs can be paged");
 
         SelectStatement select = (SelectStatement)prepared.statement;
-        QueryPager pager = 
select.getQuery(makeInternalOptions(prepared.statement, values), 
FBUtilities.nowInSeconds()).getPager(null, ProtocolVersion.CURRENT);
+        int nowInSec = FBUtilities.nowInSeconds();
+        QueryPager pager = 
select.getQuery(makeInternalOptionsWithNowInSec(prepared.statement, nowInSec, 
values), nowInSec).getPager(null, ProtocolVersion.CURRENT);
         return UntypedResultSet.create(select, pager, pageSize);
     }
 
@@ -575,7 +576,7 @@ public class QueryProcessor implements QueryHandler
     {
         CQLStatement statement = parseStatement(query, 
queryState.getClientState());
         statement.validate(queryState.getClientState());
-        ResultMessage result = statement.executeLocally(queryState, 
makeInternalOptions(statement, values));
+        ResultMessage result = statement.executeLocally(queryState, 
makeInternalOptionsWithNowInSec(statement, queryState.getNowInSeconds(), 
values));
         if (result instanceof ResultMessage.Rows)
             return 
UntypedResultSet.create(((ResultMessage.Rows)result).result);
         else
@@ -592,7 +593,7 @@ public class QueryProcessor implements QueryHandler
         Prepared prepared = prepareInternal(query);
         assert prepared.statement instanceof SelectStatement;
         SelectStatement select = (SelectStatement)prepared.statement;
-        ResultMessage result = select.executeInternal(internalQueryState(), 
makeInternalOptions(prepared.statement, values), nowInSec, queryStartNanoTime);
+        ResultMessage result = select.executeInternal(internalQueryState(), 
makeInternalOptionsWithNowInSec(prepared.statement, nowInSec, values), 
nowInSec, queryStartNanoTime);
         assert result instanceof ResultMessage.Rows;
         return UntypedResultSet.create(((ResultMessage.Rows)result).result);
     }
@@ -606,8 +607,8 @@ public class QueryProcessor implements QueryHandler
     {
         Prepared prepared = prepareInternal(query);
         assert prepared.statement instanceof SelectStatement;
-        SelectStatement select = (SelectStatement)prepared.statement;
-        return 
select.executeRawInternal(makeInternalOptions(prepared.statement, values), 
internalQueryState().getClientState(), nowInSec);
+        SelectStatement select = (SelectStatement) prepared.statement;
+        return 
select.executeRawInternal(makeInternalOptionsWithNowInSec(prepared.statement, 
nowInSec, values), internalQueryState().getClientState(), nowInSec);
     }
 
     public static UntypedResultSet resultify(String query, RowIterator 
partition)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to