aweisberg commented on code in PR #4696:
URL: https://github.com/apache/cassandra/pull/4696#discussion_r3041190535
##########
src/java/org/apache/cassandra/service/replication/migration/KeyspaceMigrationInfo.java:
##########
@@ -246,6 +270,107 @@ public boolean shouldUseTrackedForWrites(boolean
isTracked, TableId tableId, Tok
return isTracked || isTokenInPendingRange(tableId, token);
}
+ /**
+ * Asserts that the given ranges are either entirely inside or entirely
outside the pending
+ * migration set for each specified table. During migration, reads for
pending ranges continue
+ * to use the untracked read path with blocking read repair, so it is safe
to exclude mutation
+ * tracking streaming for those ranges. However, partial overlap is not
supported — repair must
+ * operate on ranges that are fully migrated or fully pending.
+ *
+ * @param ranges the normalized ranges to check
+ * @param tables the tables to check against
+ * @throws IllegalStateException if ranges partially overlap with pending
ranges for any table
+ */
+ public void assertRangesNotMixedMigration(@Nonnull NormalizedRanges<Token>
ranges,
+ @Nonnull Iterable<TableMetadata>
tables)
+ {
+ for (TableMetadata table : tables)
+ {
+ NormalizedRanges<Token> pendingRanges =
getPendingRangesForTable(table.id);
+ if (pendingRanges.isEmpty())
+ continue;
+
+ NormalizedRanges<Token> overlap =
pendingRanges.intersection(ranges);
+ if (overlap.isEmpty())
+ continue;
+
+ // Some ranges overlap with pending — verify ALL ranges are
pending for this table
+ NormalizedRanges<Token> outside = ranges.subtract(pendingRanges);
+ if (!outside.isEmpty())
+ throw new IllegalStateException(String.format(
+ "Ranges for keyspace %s partially overlap with migration
pending ranges for table %s. " +
+ "Ranges must be entirely inside or entirely outside the
pending set.",
+ keyspace, table.name));
+ }
+ }
+
+ /**
+ * Convenience overload that resolves column family names to table
metadata before checking.
+ * If columnFamilies is empty, all tables in the keyspace are checked.
+ *
+ * @param ranges the normalized ranges to check
+ * @param ksm the keyspace metadata for resolving table names
+ * @param columnFamilies specific table names to check, or empty for all
tables
+ * @throws IllegalStateException if ranges partially overlap with pending
ranges for any table
+ */
+ public void assertRangesNotMixedMigration(@Nonnull NormalizedRanges<Token>
ranges,
+ @Nonnull KeyspaceMetadata ksm,
+ @Nonnull Collection<String>
columnFamilies)
+ {
+ Iterable<TableMetadata> tables;
+ if (!columnFamilies.isEmpty())
Review Comment:
That is an artifact of how RepairOption treats the empty set as "all
tables". I'll update this method to use null and then fix it at the caller to
convert an empty set to null.
--
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]