aweisberg commented on code in PR #4508:
URL: https://github.com/apache/cassandra/pull/4508#discussion_r2611358129
##########
src/java/org/apache/cassandra/service/replication/migration/MigrationRouter.java:
##########
@@ -305,19 +308,39 @@ public static RoutedMutations routeMutations(List<?
extends IMutation> mutations
return routeMutations(ClusterMetadata.current(), mutations);
}
- public static boolean isFullyTracked(IMutation mutation)
+ public enum MutationRouting
{
- // System keyspaces never use tracked replication
+ TRACKED, UNTRACKED, MIXED
+ }
+
+ public static MutationRouting getMutationRouting(IMutation mutation)
+ {
+ // System keyspaces always use untracked replication
if (SchemaConstants.isSystemKeyspace(mutation.getKeyspaceName()))
- return false;
+ return MutationRouting.UNTRACKED;
ClusterMetadata cm = ClusterMetadata.current();
String keyspace = mutation.getKeyspaceName();
Token token = mutation.key().getToken();
+
+ MutationRouting result = null;
for (TableId tableId : mutation.getTableIds())
- if (!shouldUseTrackedForWrites(cm, keyspace, tableId, token))
- return false;
+ {
+ MutationRouting routing = shouldUseTrackedForWrites(cm, keyspace,
tableId, token)
+ ? MutationRouting.TRACKED
+ : MutationRouting.UNTRACKED;
+
+ if (result == null)
+ result = routing;
+ else if (result != routing)
+ return MutationRouting.MIXED;
Review Comment:
You could error out here really and not have to expose a complex return
value. It's would have to be a bug in `shouldUseTrackedForWrites`.
This is maybe even more complicated than it has to be and could be
simplified. If a single table in the mutation has mutation routing enabled then
by definition all the others also do since it's a keyspace level attribute that
doesn't depend on any migration state and mutations can only operate on a
single keyspace. You don't even really need to check for the mixed case since
that is just an artifact of assuming that `shouldUseTrackedForWrites` might
return different values for different tables in the same keyspace which is kind
of nonsensical when you think about it.
--
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]