maedhroz commented on code in PR #4426:
URL: https://github.com/apache/cassandra/pull/4426#discussion_r2608466504


##########
src/java/org/apache/cassandra/db/compaction/CompactionManager.java:
##########
@@ -1493,18 +1504,39 @@ void scrubOne(ColumnFamilyStore cfs, 
LifecycleTransaction modifier, IScrubber.Op
     @VisibleForTesting
     void verifyOne(ColumnFamilyStore cfs, SSTableReader sstable, 
IVerifier.Options options, ActiveCompactionsTracker activeCompactions)
     {
+
+        StorageAttachedIndexGroup indexGroup = 
StorageAttachedIndexGroup.getIndexGroup(cfs);
+        boolean skipSaiCheck = indexGroup == null || 
SchemaConstants.isSystemKeyspace(cfs.getKeyspaceName());
+
+        // If this table shouldn’t be verified, we skip early
+        if (options.onlySai && skipSaiCheck)
+        {
+            logger.info("Skipping SAI validation for table {} (system keyspace 
or no SAI index).", cfs.getTableName());
+            return;
+        }
+
         CompactionInfo.Holder verifyInfo = null;
-        try (IVerifier verifier = sstable.getVerifier(cfs, new 
OutputHandler.LogOutput(), false, options))
+
+        if (!options.onlySai)
         {
-            verifyInfo = verifier.getVerifyInfo();
-            activeCompactions.beginCompaction(verifyInfo);
-            verifier.verify();
+            try(IVerifier verifier = sstable.getVerifier(cfs, new 
OutputHandler.LogOutput(), false, options))

Review Comment:
   ```suggestion
               try (IVerifier verifier = sstable.getVerifier(cfs, new 
OutputHandler.LogOutput(), false, options))
   ```



##########
src/java/org/apache/cassandra/db/compaction/CompactionManager.java:
##########
@@ -1493,18 +1504,39 @@ void scrubOne(ColumnFamilyStore cfs, 
LifecycleTransaction modifier, IScrubber.Op
     @VisibleForTesting
     void verifyOne(ColumnFamilyStore cfs, SSTableReader sstable, 
IVerifier.Options options, ActiveCompactionsTracker activeCompactions)
     {
+
+        StorageAttachedIndexGroup indexGroup = 
StorageAttachedIndexGroup.getIndexGroup(cfs);
+        boolean skipSaiCheck = indexGroup == null || 
SchemaConstants.isSystemKeyspace(cfs.getKeyspaceName());
+
+        // If this table shouldn’t be verified, we skip early
+        if (options.onlySai && skipSaiCheck)
+        {
+            logger.info("Skipping SAI validation for table {} (system keyspace 
or no SAI index).", cfs.getTableName());
+            return;
+        }
+
         CompactionInfo.Holder verifyInfo = null;
-        try (IVerifier verifier = sstable.getVerifier(cfs, new 
OutputHandler.LogOutput(), false, options))
+
+        if (!options.onlySai)
         {
-            verifyInfo = verifier.getVerifyInfo();
-            activeCompactions.beginCompaction(verifyInfo);
-            verifier.verify();
+            try(IVerifier verifier = sstable.getVerifier(cfs, new 
OutputHandler.LogOutput(), false, options))
+            {
+                verifyInfo = verifier.getVerifyInfo();
+                activeCompactions.beginCompaction(verifyInfo);
+                verifier.verify();
+            }
+            finally
+            {
+                if (verifyInfo != null)
+                    activeCompactions.finishCompaction(verifyInfo);
+            }
         }
-        finally
+
+        if ((options.onlySai || options.includeSai) && !skipSaiCheck)
         {
-            if (verifyInfo != null)
-                activeCompactions.finishCompaction(verifyInfo);
+            
cfs.indexManager.validateSSTableAttachedIndexes(Collections.singleton(sstable), 
true, true);
         }
+

Review Comment:
   nit: extra newline



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