Scenario: Number of Racks > RF (RF=2, 3 Racks)
Racks: R1, R2, R3
Nodes: N1 (R1), N2 (R2), N3 (R3), N4 (R1), N5 (R2), N6 (R3)
Walking the ring:
Primary Replica: Placed on N1 (R1).
Next Replica: Placed on N2 (R2)
Scenario: RF == Number of Racks (RF=3, 3 Racks)
Racks: R1, R2, R3
Nodes: N1 (R1), N2 (R2), N3 (R3), N4 (R1), N5 (R2), N6 (R3)
Walking the ring:
Primary Replica: Placed on N1 (R1).
Next Replica: Placed on N2 (R2)
Next Replica: Placed on N3 (R3)
It seems in both scenarios you will ensure unique racks for each replica. I must be missing something for why the condition exists. https://github.com/apache/cassandra/blob/cassandra-5.0/src/java/org/apache/cassandra/dht/tokenallocator/TokenAllocation.java#L257