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


##########
src/java/org/apache/cassandra/service/StorageProxy.java:
##########
@@ -2141,28 +2149,77 @@ private static PartitionIterator 
readWithConsensus(SinglePartitionReadCommand.Gr
         return lastResult.serialReadResult;
     }
 
-    private static ConsensusAttemptResult 
readWithAccord(SinglePartitionReadCommand.Group group, ConsistencyLevel 
consistencyLevel, Dispatcher.RequestTime requestTime)
+    private static ConsistencyLevel 
consistencyLevelForAccordRead(ClusterMetadata cm, 
SinglePartitionReadCommand.Group group, @Nullable ConsistencyLevel 
consistencyLevel)
+    {
+        // Null means no specific consistency behavior is required from 
Accord, it's functionally similar to
+        // reading at ONE if you are reading data that wasn't written via 
Accord
+        if (consistencyLevel == null)
+            return null;
+
+        TableId tableId = group.queries.get(0).metadata().id;
+        TableParams tableParams = getTableMetadata(cm, tableId).params;
+        TransactionalMode mode = tableParams.transactionalMode;
+        TransactionalMigrationFromMode migrationFromMode = 
tableParams.transactionalMigrationFrom;
+        for (SinglePartitionReadCommand command : group.queries)
+        {
+            // readCLForStrategy should return either null or the supplied 
consistency level
+            // in which case we will read everything at that CL since Accord 
doesn't support per table
+            // read consistency
+            ConsistencyLevel commitCL = 
mode.readCLForStrategy(migrationFromMode, consistencyLevel, cm, tableId, 
command.partitionKey().getToken());
+            if (commitCL != null)
+                return commitCL;
+        }
+        return null;
+    }
+
+    private static ConsensusAttemptResult readWithAccord(ClusterMetadata cm, 
SinglePartitionReadCommand.Group group, ConsistencyLevel consistencyLevel, 
Dispatcher.RequestTime requestTime)
     {
-        if (group.queries.size() > 1)
-            throw new InvalidRequestException("SERIAL/LOCAL_SERIAL consistency 
may only be requested for one partition at a time");
-        SinglePartitionReadCommand readCommand = group.queries.get(0);
         // If the non-SERIAL write strategy is sending all writes through 
Accord there is no need to use the supplied consistency
         // level since Accord will manage reading safely
         TransactionalMode transactionalMode = 
group.metadata().params.transactionalMode;
-        consistencyLevel = 
transactionalMode.readCLForStrategy(consistencyLevel);
-        TxnRead read = TxnRead.createSerialRead(readCommand, consistencyLevel);
-        Invariants.checkState(read.keys().size() == 1, "Ephemeral reads are 
only strict-serializable for single partition reads");
-        Txn txn = new Txn.InMemory(transactionalMode == TransactionalMode.full 
&& DatabaseDescriptor.getAccordEphemeralReadEnabledEnabled() ? EphemeralRead : 
Read, read.keys(), read, TxnQuery.ALL, null);
-        IAccordService accordService = AccordService.instance();
-        TxnResult txnResult = accordService.coordinate(txn, consistencyLevel, 
requestTime);
+        consistencyLevel = consistencyLevelForAccordRead(cm, group, 
consistencyLevel);
+        TxnRead read = TxnRead.createSerialRead(group.queries, 
consistencyLevel);

Review Comment:
   `TxnRead.createSerialRead` is an old name (before we had non-serial reading 
through Accord)  and it doesn't indicate a difference in how the read works. 
`TxnRead` has a naming scheme using `TxnDataName` for all the reads in a 
transaction are stored and this is just a helper method for creating the 
`TxnDataName` for each read.
   
   How the read is actually executed by Accord (single replica, QUORUM, ALL) is 
determined by the value of `consistencyLevel`.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to