This is an automated email from the ASF dual-hosted git repository.

mck pushed a commit to branch cassandra-5.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/cassandra-5.0 by this push:
     new 3928f2992f Provide truncate task for SAI
3928f2992f is described below

commit 3928f2992f94aa2b4e56bee0f36a0bdb31087116
Author: Mike Adamson <[email protected]>
AuthorDate: Mon Nov 27 13:06:33 2023 +0000

    Provide truncate task for SAI
    
    If a table is truncated during the initial build of an index there is a 
chance that the index build will get interrupted and it won't get marked 
queryable. This patch provides a truncate task for SAI that marks the index 
queryable during truncation.
    
     patch by Mike Adamson; reviewed by Caleb Rackliffe, Michael Semb Wever for 
CASSANDRA-19032
---
 CHANGES.txt                                                   |  1 +
 .../org/apache/cassandra/index/sai/StorageAttachedIndex.java  | 11 ++++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 09f3d96c06..671be30550 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 5.0-beta1
+ * SAI indexes are marked queryable during truncation (CASSANDRA-19032)
  * Enable Direct-IO feature for CommitLog files using Java native API's. 
(CASSANDRA-18464)
  * SAI fixes for composite partitions, and static and non-static rows 
intersections (CASSANDRA-19034)
  * Improve SAI IndexContext handling of indexed and non-indexed columns in 
queries (CASSANDRA-18166)
diff --git a/src/java/org/apache/cassandra/index/sai/StorageAttachedIndex.java 
b/src/java/org/apache/cassandra/index/sai/StorageAttachedIndex.java
index 4304a3edfe..49d93bd643 100644
--- a/src/java/org/apache/cassandra/index/sai/StorageAttachedIndex.java
+++ b/src/java/org/apache/cassandra/index/sai/StorageAttachedIndex.java
@@ -390,10 +390,15 @@ public class StorageAttachedIndex implements Index
     public Callable<?> getTruncateTask(long truncatedAt)
     {
         /*
-         * index files will be removed as part of base sstable lifecycle in
-         * {@link LogTransaction#delete(java.io.File)} asynchronously.
+         * index files will be removed as part of base sstable lifecycle in 
{@link LogTransaction#delete(java.io.File)}
+         * asynchronously, but we need to mark the index queryable because if 
the truncation is during the initial
+         * build of the index it won't get marked queryable by the build.
          */
-        return null;
+        return () -> {
+            logger.info(indexIdentifier.logMessage("Making index queryable 
during table truncation"));
+            baseCfs.indexManager.makeIndexQueryable(this, 
Status.BUILD_SUCCEEDED);
+            return null;
+        };
     }
 
     @Override


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to