krummas commented on code in PR #4365:
URL: https://github.com/apache/cassandra/pull/4365#discussion_r2374616565


##########
src/java/org/apache/cassandra/repair/consistent/LocalSessions.java:
##########
@@ -239,21 +240,43 @@ private boolean shouldStoreSession(LocalSession session)
      */
     private boolean isSuperseded(LocalSession session)
     {
+        // to reduce overheads of intersect calculation for tables within the 
same keyspace
+        Map<String, List<Range<Token>>> rangesPerKeyspaceCache = new 
HashMap<>();
         for (TableId tid : session.tableIds)
         {
-            RepairedState state = repairedStates.get(tid);
+            TableMetadata tableMetadata = getTableMetadata(tid);
+            if (tableMetadata == null) // if a table was removed - ignore it
+                continue;
 
+            RepairedState state = repairedStates.get(tid);
             if (state == null)
                 return false;
 
-            long minRepaired = state.minRepairedAt(session.ranges);
+            Collection<Range<Token>> actualRanges = 
rangesPerKeyspaceCache.computeIfAbsent(tableMetadata.keyspace, (keyspace) -> {
+                // ignore token ranges which were moved to other nodes and not 
onwed by the current one anymore
+                List<Range<Token>> localRanges = 
getLocalRanges(tableMetadata.keyspace);

Review Comment:
   Maybe add a check if local ranges is empty here - if for some reason we move 
cleanup to run before tokenmetadata is properly populated (or in later versions 
tcm log is replayed) we would remove all sessions



-- 
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