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

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

commit f378f92030f3813ebcff7be155f526500af7ac21
Merge: 875793bc19 d54646e409
Author: Caleb Rackliffe <calebrackli...@gmail.com>
AuthorDate: Tue Jul 2 14:05:23 2024 -0500

    Merge branch 'cassandra-4.0' into cassandra-4.1
    
    * cassandra-4.0:
      UnsupportedOperationException when reducing scope for LCS compactions

 CHANGES.txt                                        |  1 +
 .../db/compaction/LeveledCompactionTask.java       |  2 +-
 .../test/LeveledCompactionTaskTest.java            | 92 ++++++++++++++++++++++
 3 files changed, 94 insertions(+), 1 deletion(-)

diff --cc CHANGES.txt
index 4028f905ef,52ec8bc211..cdceaa802d
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -11,13 -7,7 +11,14 @@@ Merged from 3.0
   * Upgrade OWASP to 10.0.0 (CASSANDRA-19738)
  
  
 -4.0.13
 +4.1.5
 + * Make queries visible to the "system_views.queries" virtual table at the 
coordinator level (CASSANDRA-19577)
 + * Concurrent equivalent schema updates lead to unresolved disagreement 
(CASSANDRA-19578)
 + * Fix hints delivery for a node going down repeatedly (CASSANDRA-19495)
 + * Do not go to disk for reading hints file sizes (CASSANDRA-19477)
 + * Fix system_views.settings to handle array types (CASSANDRA-19475)
 +Merged from 4.0:
++ * UnsupportedOperationException when reducing scope for LCS compactions 
(CASSANDRA-19704)
   * Make nodetool import congruent with the documentation by not relying on 
the folder structure of the imported SSTable files (CASSANDRA-19401)
   * IR may leak SSTables with pending repair when coming from streaming 
(CASSANDRA-19182)
   * Streaming exception race creates corrupt transaction log files that 
prevent restart (CASSANDRA-18736)
diff --cc 
test/distributed/org/apache/cassandra/distributed/test/LeveledCompactionTaskTest.java
index 0000000000,f1051e6109..dccad716e2
mode 000000,100644..100644
--- 
a/test/distributed/org/apache/cassandra/distributed/test/LeveledCompactionTaskTest.java
+++ 
b/test/distributed/org/apache/cassandra/distributed/test/LeveledCompactionTaskTest.java
@@@ -1,0 -1,88 +1,92 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *     http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ 
+ package org.apache.cassandra.distributed.test;
+ 
+ import java.io.IOException;
+ 
+ import org.junit.Test;
+ 
+ import net.bytebuddy.ByteBuddy;
+ import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
+ import net.bytebuddy.implementation.MethodDelegation;
+ import org.apache.cassandra.db.Directories;
+ import org.apache.cassandra.db.Keyspace;
+ import org.apache.cassandra.distributed.Cluster;
+ import org.apache.cassandra.distributed.api.ConsistencyLevel;
+ 
+ import static net.bytebuddy.matcher.ElementMatchers.named;
+ import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
+ import static org.junit.Assert.fail;
+ 
+ public class LeveledCompactionTaskTest extends TestBaseImpl
+ {
+     @Test
+     public void testBuildCompactionCandidatesForAvailableDiskSpace() throws 
IOException
+     {
 -        try (Cluster cluster = 
init(builder().withNodes(1).withInstanceInitializer(BB::install).start()))
++        try (Cluster cluster = init(builder().withNodes(1)
++                                             .withConfig(config -> 
config.set("autocompaction_on_startup_enabled", false))
++                                             
.withInstanceInitializer(BB::install).start()))
+         {
+             cluster.schemaChange(withKeyspace("CREATE TABLE %s.tbl (id int 
primary key) WITH compaction = {'class':'LeveledCompactionStrategy', 
'enabled':'false'}"));
+             for (int i = 0; i < 100; i++)
+             {
+                 cluster.coordinator(1).execute(withKeyspace("INSERT INTO 
%s.tbl (id) VALUES (?)"), ConsistencyLevel.ALL, i);
+                 if (i % 10 == 0)
+                     cluster.get(1).flush(KEYSPACE);
+             }
+             cluster.get(1).flush(KEYSPACE);
+             cluster.setUncaughtExceptionsFilter((exception) -> 
exception.getMessage() != null && exception.getMessage().contains("Not enough 
space for compaction"));
+ 
+             cluster.get(1).runOnInstance(() -> {
++                BB.hasDiskSpaceResult = false;
+                 try
+                 {
+                     
Keyspace.open(KEYSPACE).getColumnFamilyStore("tbl").enableAutoCompaction(true);
+                     fail("This should fail, but only due to having no disk 
space");
+                 }
+                 catch (Exception e)
+                 {
+                     if (!(e.getMessage() != null && 
e.getMessage().contains("Not enough space for compaction")))
+                         throw e;
+                 }
+             });
 -
+         }
+     }
+ 
+     public static class BB
+     {
++        static volatile boolean hasDiskSpaceResult = true;
++
+         @SuppressWarnings("resource")
+         public static void install(ClassLoader cl, int id)
+         {
+             new ByteBuddy().rebase(Directories.class)
+                            
.method(named("hasAvailableDiskSpace").and(takesArguments(2)))
+                            .intercept(MethodDelegation.to(BB.class))
+                            .make()
+                            .load(cl, ClassLoadingStrategy.Default.INJECTION);
+         }
+ 
+         @SuppressWarnings("unused")
+         public static boolean hasAvailableDiskSpace(long estimatedSSTables, 
long expectedTotalWriteSize)
+         {
 -            return false;
++            return hasDiskSpaceResult;
+         }
+     }
+ }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to