You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "mike-tr-adamson (via GitHub)" <gi...@apache.org> on 2023/11/27 13:58:04 UTC

[PR] CASSANDRA-19032 Provide truncate task for SAI [cassandra]

mike-tr-adamson opened a new pull request, #2932:
URL: https://github.com/apache/cassandra/pull/2932

   If a table is truncated during the initial build of an SAI 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.


-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-19032 Provide truncate task for SAI [cassandra]

Posted by "mike-tr-adamson (via GitHub)" <gi...@apache.org>.
mike-tr-adamson commented on code in PR #2932:
URL: https://github.com/apache/cassandra/pull/2932#discussion_r1406581646


##########
src/java/org/apache/cassandra/index/sai/StorageAttachedIndex.java:
##########
@@ -390,10 +390,15 @@ public Callable<?> getPreJoinTask(boolean hadBootstrap)
     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.

Review Comment:
   I am working on the basis that if we truncate we will delete any existing data (sstable and index). As a result, we can safely mark the index as queryable and let further errors mark it not-queryable.  



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-19032 Provide truncate task for SAI [cassandra]

Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #2932:
URL: https://github.com/apache/cassandra/pull/2932#discussion_r1406608665


##########
src/java/org/apache/cassandra/index/sai/StorageAttachedIndex.java:
##########
@@ -390,10 +390,15 @@ public Callable<?> getPreJoinTask(boolean hadBootstrap)
     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.

Review Comment:
   Most clusters I work on don't even allow truncation in production :p



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-19032 Provide truncate task for SAI [cassandra]

Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #2932:
URL: https://github.com/apache/cassandra/pull/2932#discussion_r1406610291


##########
src/java/org/apache/cassandra/index/sai/StorageAttachedIndex.java:
##########
@@ -390,10 +390,15 @@ public Callable<?> getPreJoinTask(boolean hadBootstrap)
     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"));

Review Comment:
   Yeah, that makes sense. The other thing I forgot is that `makeIndexQueryable()` has its own logging, maybe adding a new `Index.Status` for truncation would allow us to just piggyback on that...
   
   ```
   logger.info("Index [{}] became queryable after successful build.", name);
   ```
   
   ...message?



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-19032 Provide truncate task for SAI [cassandra]

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on PR #2932:
URL: https://github.com/apache/cassandra/pull/2932#issuecomment-1831850327

   Committed https://github.com/apache/cassandra/commit/3928f2992f94aa2b4e56bee0f36a0bdb31087116


-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-19032 Provide truncate task for SAI [cassandra]

Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #2932:
URL: https://github.com/apache/cassandra/pull/2932#discussion_r1406576686


##########
src/java/org/apache/cassandra/index/sai/StorageAttachedIndex.java:
##########
@@ -390,10 +390,15 @@ public Callable<?> getPreJoinTask(boolean hadBootstrap)
     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"));

Review Comment:
   ```suggestion
               logger.info(indexIdentifier.logMessage("Making index queryable during table truncation..."));
   ```
   nit: Totally don't have to do this, but I like throwing ellipses on there when it's something we're about to do ;)



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-19032 Provide truncate task for SAI [cassandra]

Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #2932:
URL: https://github.com/apache/cassandra/pull/2932#discussion_r1406575124


##########
src/java/org/apache/cassandra/index/sai/StorageAttachedIndex.java:
##########
@@ -390,10 +390,15 @@ public Callable<?> getPreJoinTask(boolean hadBootstrap)
     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.

Review Comment:
   If the index is currently marked as non-queryable, and we truncate, is this safe because truncation will remove all the on-disk artifacts (or lack of those artifacts) that made the index non-queryable in the first place? (Still thinking through this, but want to make sure there's no way we accidentally make an index queryable when we shouldn't...)



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-19032 Provide truncate task for SAI [cassandra]

Posted by "mike-tr-adamson (via GitHub)" <gi...@apache.org>.
mike-tr-adamson commented on code in PR #2932:
URL: https://github.com/apache/cassandra/pull/2932#discussion_r1407578418


##########
src/java/org/apache/cassandra/index/sai/StorageAttachedIndex.java:
##########
@@ -390,10 +390,15 @@ public Callable<?> getPreJoinTask(boolean hadBootstrap)
     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"));

Review Comment:
   It starts to get messy if we do that. There is a lot of code that depends on `BUILD_SUCCEEDED`. If we add a new status, we would need to handle that correctly. I'd prefer to leave this as is. As you say, truncation is a bad idea anyway. 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-19032 Provide truncate task for SAI [cassandra]

Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #2932:
URL: https://github.com/apache/cassandra/pull/2932#discussion_r1406690439


##########
src/java/org/apache/cassandra/index/sai/StorageAttachedIndex.java:
##########
@@ -390,10 +390,15 @@ public Callable<?> getPreJoinTask(boolean hadBootstrap)
     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.

Review Comment:
   Looked at this a bit more, and I think we're safe. Truncation should clear any existing rationale for "non-queryability" and also should do it after interrupting ongoing builds/compactions.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-19032 Provide truncate task for SAI [cassandra]

Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #2932:
URL: https://github.com/apache/cassandra/pull/2932#discussion_r1406575124


##########
src/java/org/apache/cassandra/index/sai/StorageAttachedIndex.java:
##########
@@ -390,10 +390,15 @@ public Callable<?> getPreJoinTask(boolean hadBootstrap)
     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.

Review Comment:
   If the index is currently marked as non-queryable, and we truncate, is this safe because truncation will remove all the on-disk artifacts (or lack of those artifacts) that made the index non-queryable in the first place?



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-19032 Provide truncate task for SAI [cassandra]

Posted by "mike-tr-adamson (via GitHub)" <gi...@apache.org>.
mike-tr-adamson commented on code in PR #2932:
URL: https://github.com/apache/cassandra/pull/2932#discussion_r1406589699


##########
src/java/org/apache/cassandra/index/sai/StorageAttachedIndex.java:
##########
@@ -390,10 +390,15 @@ public Callable<?> getPreJoinTask(boolean hadBootstrap)
     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"));

Review Comment:
   I don't have an issue with that, except that I'd usually leave it for something that was going to take a little time to complete. This is just setting a flag. If you feel it needs it I'm happy for the change.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-19032 Provide truncate task for SAI [cassandra]

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever closed pull request #2932: CASSANDRA-19032 Provide truncate task for SAI
URL: https://github.com/apache/cassandra/pull/2932


-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org