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
This commit is contained in:
Mike Adamson 2023-11-27 13:06:33 +00:00 committed by Mick Semb Wever
parent 3396ce9f08
commit 3928f2992f
No known key found for this signature in database
GPG Key ID: E91335D77E3E87CB
2 changed files with 9 additions and 3 deletions

View File

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

View File

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