aweisberg commented on code in PR #4328:
URL: https://github.com/apache/cassandra/pull/4328#discussion_r2298902243


##########
src/java/org/apache/cassandra/cql3/statements/TransactionStatement.java:
##########
@@ -467,15 +475,47 @@ public Txn createTxn(ClientState state, QueryOptions 
options)
         {
             Int2ObjectHashMap<NamedSelect> autoReads = new 
Int2ObjectHashMap<>();
             List<TxnWrite.Fragment> writeFragments = 
createWriteFragments(state, options, autoReads, keyCollector);
-            ConsistencyLevel commitCL = consistencyLevelForAccordCommit(cm, 
tables, keyCollector, options.getConsistency());
             List<TxnNamedRead> reads = createNamedReads(options, autoReads, 
keyCollector);
+            if (writeFragments.isEmpty()) // ModificationStatement yield no 
Mutation (DELETE WHERE pk=0 AND c < 0 AND c > 0 -- matches no keys; so has no 
mutation)
+            {
+                // cleanup memory
+                keyCollector.clear();
+                autoReads.clear();
+                return maybeCreateTxnFromEmptyWrites(cm, options, tables);
+            }
+            ConsistencyLevel commitCL = consistencyLevelForAccordCommit(cm, 
tables, keyCollector, options.getConsistency());
             Keys keys = keyCollector.build();
             AccordUpdate update = new TxnUpdate(tables, writeFragments, 
createCondition(options), commitCL, PreserveTimestamp.no);
             TxnRead read = createTxnRead(tables, reads, null, Domain.Key);
             return new Txn.InMemory(keys, read, TxnQuery.ALL, update, new 
TableMetadatasAndKeys(tables, keys));
         }
     }
 
+    @Nullable
+    private Txn.InMemory maybeCreateTxnFromEmptyWrites(ClusterMetadata cm, 
QueryOptions options, TableMetadatas.Complete tables)
+    {
+        TableMetadatasAndKeys.KeyCollector keyCollector = new 
TableMetadatasAndKeys.KeyCollector(tables);
+        List<TxnNamedRead> reads = createNamedReads(options, null, 
keyCollector);
+        if (reads.isEmpty())
+        {
+            // no reads, this is a no-op
+            noSpamLogger.info(WRITE_TXN_EMPTY_WITH_NO_READS);
+            return null;
+        }
+        if (returningSelect == null && returningReferences == null)
+        {
+            // the reads were for the mutation, and since the mutation doesn't 
exist the reads are not needed

Review Comment:
   When does this case occur?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to