aweisberg commented on code in PR #4508:
URL: https://github.com/apache/cassandra/pull/4508#discussion_r2628531907
##########
src/java/org/apache/cassandra/db/AbstractMutationVerbHandler.java:
##########
@@ -193,6 +196,49 @@ else if
(message.epoch().isBefore(metadata.schema.lastModified()))
return metadata;
}
+ /**
+ * Confirm that the presence/absence of a mutation id matches our
expectations for the given keyspace/table/token. If
+ * it doesn't, then we're not on the same epoch as the coordinator, or
there's a bug.
+ */
+ private ClusterMetadata checkReplicationMigration(ClusterMetadata
metadata, Message<T> message, InetAddressAndPort respondTo)
+ {
+ IMutation mutation = message.payload;
+ MutationRouting expected = mutation.id().isNone() ?
MutationRouting.UNTRACKED : MutationRouting.TRACKED;
+ if (expected == MigrationRouter.getMutationRouting(metadata, mutation))
+ return metadata;
+
+ if (message.epoch().isAfter(metadata.epoch))
+ {
+ // coordinator is ahead, fetch log and recheck
+ metadata =
ClusterMetadataService.instance().fetchLogFromPeerOrCMS(metadata, respondTo,
message.epoch());
+ if (expected != MigrationRouter.getMutationRouting(metadata,
mutation))
+ throw new IllegalStateException(String.format("Inconsistent
mutation routing after fetching log for epoch = %s. Keyspace: %s key: %s ",
+ metadata.epoch,
+
mutation.getKeyspaceName(),
+ mutation.key()));
+ }
+ else if (message.epoch().isBefore(metadata.epoch))
+ {
+ TCMMetrics.instance.coordinatorBehindReplication.mark();
+ throw new CoordinatorBehindException(String.format("Replication
type / migration mismatch for keyspace: %s token %s, coordinator: %s is behind,
our epoch = %s, their epoch = %s",
Review Comment:
This check needs to be done in the write op order to work with the happens
before in repair so it should be in Keyspace.apply
--
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]