You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ma...@apache.org on 2022/12/23 13:54:08 UTC

[cassandra] branch cassandra-4.0 updated (ace3920239 -> 95e26ad1ab)

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

marcuse pushed a change to branch cassandra-4.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git


    from ace3920239 Merge branch 'cassandra-3.11' into cassandra-4.0
     new 730b898b74 Don't group TWCS sstables for anticompaction
     new 0767c83416 Merge branch 'cassandra-3.0' into cassandra-3.11
     new 95e26ad1ab Merge branch 'cassandra-3.11' into cassandra-4.0

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CHANGES.txt                                        |  1 +
 .../compaction/TimeWindowCompactionStrategy.java   | 14 +++++++++++++
 .../TimeWindowCompactionStrategyTest.java          | 24 ++++++++++++++++++++++
 .../org/apache/cassandra/schema/MockSchema.java    | 19 +++++++++++++----
 4 files changed, 54 insertions(+), 4 deletions(-)


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


[cassandra] 01/01: Merge branch 'cassandra-3.11' into cassandra-4.0

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 95e26ad1ab29b52e720edf9792eba100817cce9d
Merge: ace3920239 0767c83416
Author: Marcus Eriksson <ma...@apache.org>
AuthorDate: Fri Dec 23 14:43:01 2022 +0100

    Merge branch 'cassandra-3.11' into cassandra-4.0

 CHANGES.txt                                        |  1 +
 .../compaction/TimeWindowCompactionStrategy.java   | 14 +++++++++++++
 .../TimeWindowCompactionStrategyTest.java          | 24 ++++++++++++++++++++++
 .../org/apache/cassandra/schema/MockSchema.java    | 19 +++++++++++++----
 4 files changed, 54 insertions(+), 4 deletions(-)

diff --cc CHANGES.txt
index 1cb2280828,ee21b34ebc..f7dddd37b1
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,12 -1,8 +1,13 @@@
 -3.11.15
 +4.0.8
 + * Restore internode custom tracing on 4.0's new messaging system (CASSANDRA-17981)
 + * Harden parsing of boolean values in CQL in PropertyDefinitions (CASSANDRA-17878)
 + * Fix error message about type hints (CASSANDRA-17915)
 + * Fix possible race condition on repair snapshots (CASSANDRA-17955)
 + * Fix ASM bytecode version inconsistency (CASSANDRA-17873)
 +Merged from 3.11:
   * Fix Splitter sometimes creating more splits than requested (CASSANDRA-18013)
 -
  Merged from 3.0:
+  * Avoid anticompaction mixing data from two different time windows with TWCS (CASSANDRA-17970)
   * Do not spam the logs with MigrationCoordinator not being able to pull schemas (CASSANDRA-18096)
   * Fix incorrect resource name in LIST PERMISSION output (CASSANDRA-17848)
   * Suppress CVE-2022-41854 and similar (CASSANDRA-18083)
diff --cc test/unit/org/apache/cassandra/db/compaction/TimeWindowCompactionStrategyTest.java
index 38033f156e,15d2a2e705..88c63082cb
--- a/test/unit/org/apache/cassandra/db/compaction/TimeWindowCompactionStrategyTest.java
+++ b/test/unit/org/apache/cassandra/db/compaction/TimeWindowCompactionStrategyTest.java
@@@ -46,6 -47,7 +48,7 @@@ import org.apache.cassandra.db.RowUpdat
  import org.apache.cassandra.exceptions.ConfigurationException;
  import org.apache.cassandra.io.sstable.format.SSTableReader;
  import org.apache.cassandra.schema.KeyspaceParams;
 -import org.apache.cassandra.MockSchema;
++import org.apache.cassandra.schema.MockSchema;
  import org.apache.cassandra.utils.Pair;
  
  import static org.apache.cassandra.db.compaction.TimeWindowCompactionStrategy.getWindowBoundsInMillis;
diff --cc test/unit/org/apache/cassandra/schema/MockSchema.java
index 901acbfcf2,0000000000..194f3db32f
mode 100644,000000..100644
--- a/test/unit/org/apache/cassandra/schema/MockSchema.java
+++ b/test/unit/org/apache/cassandra/schema/MockSchema.java
@@@ -1,239 -1,0 +1,250 @@@
 +/*
 +* 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.schema;
 +
 +import java.io.File;
 +import java.io.IOException;
 +import java.io.RandomAccessFile;
 +import java.util.*;
 +import java.util.concurrent.atomic.AtomicInteger;
 +import java.util.function.Function;
 +
 +import com.google.common.collect.ImmutableSet;
 +
 +import org.apache.cassandra.config.DatabaseDescriptor;
 +import org.apache.cassandra.db.*;
 +import org.apache.cassandra.db.marshal.UTF8Type;
 +import org.apache.cassandra.dht.Murmur3Partitioner;
 +import org.apache.cassandra.io.sstable.Component;
 +import org.apache.cassandra.io.sstable.Descriptor;
 +import org.apache.cassandra.io.sstable.IndexSummary;
 +import org.apache.cassandra.io.sstable.format.SSTableFormat;
 +import org.apache.cassandra.io.sstable.format.SSTableReader;
 +import org.apache.cassandra.io.sstable.metadata.MetadataCollector;
 +import org.apache.cassandra.io.sstable.metadata.MetadataType;
 +import org.apache.cassandra.io.sstable.metadata.StatsMetadata;
 +import org.apache.cassandra.io.util.ChannelProxy;
 +import org.apache.cassandra.io.util.FileHandle;
 +import org.apache.cassandra.io.util.FileUtils;
 +import org.apache.cassandra.io.util.Memory;
 +import org.apache.cassandra.utils.AlwaysPresentFilter;
 +import org.apache.cassandra.utils.ByteBufferUtil;
 +
 +import static org.apache.cassandra.service.ActiveRepairService.UNREPAIRED_SSTABLE;
 +
 +public class MockSchema
 +{
 +    static
 +    {
 +        Memory offsets = Memory.allocate(4);
 +        offsets.setInt(0, 0);
 +        indexSummary = new IndexSummary(Murmur3Partitioner.instance, offsets, 0, Memory.allocate(4), 0, 0, 0, 1);
 +    }
 +    private static final AtomicInteger id = new AtomicInteger();
 +    public static final Keyspace ks = Keyspace.mockKS(KeyspaceMetadata.create("mockks", KeyspaceParams.simpleTransient(1)));
 +
 +    public static final IndexSummary indexSummary;
 +
 +    private static final File tempFile = temp("mocksegmentedfile");
 +
 +    public static Memtable memtable(ColumnFamilyStore cfs)
 +    {
 +        return new Memtable(cfs.metadata());
 +    }
 +
 +    public static SSTableReader sstable(int generation, ColumnFamilyStore cfs)
 +    {
 +        return sstable(generation, false, cfs);
 +    }
 +
 +    public static SSTableReader sstable(int generation, long first, long last, ColumnFamilyStore cfs)
 +    {
 +        return sstable(generation, 0, false, first, last, cfs);
 +    }
 +
 +    public static SSTableReader sstable(int generation, boolean keepRef, ColumnFamilyStore cfs)
 +    {
 +        return sstable(generation, 0, keepRef, cfs);
 +    }
 +
 +    public static SSTableReader sstable(int generation, int size, ColumnFamilyStore cfs)
 +    {
 +        return sstable(generation, size, false, cfs);
 +    }
 +    public static SSTableReader sstable(int generation, int size, boolean keepRef, ColumnFamilyStore cfs)
 +    {
 +        return sstable(generation, size, keepRef, generation, generation, cfs);
 +    }
 +
 +    public static SSTableReader sstableWithLevel(int generation, long firstToken, long lastToken, int level, ColumnFamilyStore cfs)
 +    {
 +        return sstable(generation, 0, false, firstToken, lastToken, level, cfs);
 +    }
 +
 +    public static SSTableReader sstableWithLevel(int generation, int size, int level, ColumnFamilyStore cfs)
 +    {
 +        return sstable(generation, size, false, generation, generation, level, cfs);
 +    }
 +
++    public static SSTableReader sstableWithTimestamp(int generation, long timestamp, ColumnFamilyStore cfs)
++    {
++        return sstable(generation, 0, false, 0, 1000, 0, Integer.MAX_VALUE, timestamp, cfs);
++    }
++
 +    public static SSTableReader sstable(int generation, int size, boolean keepRef, long firstToken, long lastToken, ColumnFamilyStore cfs)
 +    {
 +        return sstable(generation, size, keepRef, firstToken, lastToken, 0, cfs);
 +    }
 +
 +    public static SSTableReader sstable(int generation, int size, boolean keepRef, long firstToken, long lastToken, int level, ColumnFamilyStore cfs)
++    {
++        return sstable(generation, size, keepRef, firstToken, lastToken, level, Integer.MAX_VALUE, System.currentTimeMillis() * 1000, cfs);
++    }
++
++    public static SSTableReader sstable(int generation, int size, boolean keepRef, long firstToken, long lastToken, int level, int minLocalDeletionTime, long timestamp, ColumnFamilyStore cfs)
 +    {
 +        Descriptor descriptor = new Descriptor(cfs.getDirectories().getDirectoryForNewSSTables(),
 +                                               cfs.keyspace.getName(),
 +                                               cfs.getTableName(),
 +                                               generation, SSTableFormat.Type.BIG);
 +        Set<Component> components = ImmutableSet.of(Component.DATA, Component.PRIMARY_INDEX, Component.FILTER, Component.TOC);
 +        for (Component component : components)
 +        {
 +            File file = new File(descriptor.filenameFor(component));
 +            try
 +            {
 +                file.createNewFile();
 +            }
 +            catch (IOException e)
 +            {
 +            }
 +        }
 +        // .complete() with size to make sstable.onDiskLength work
 +        try (FileHandle.Builder builder = new FileHandle.Builder(new ChannelProxy(tempFile)).bufferSize(size);
 +             FileHandle fileHandle = builder.complete(size))
 +        {
 +            if (size > 0)
 +            {
 +                try
 +                {
 +                    File file = new File(descriptor.filenameFor(Component.DATA));
 +                    try (RandomAccessFile raf = new RandomAccessFile(file, "rw"))
 +                    {
 +                        raf.setLength(size);
 +                    }
 +                }
 +                catch (IOException e)
 +                {
 +                    throw new RuntimeException(e);
 +                }
 +            }
 +            SerializationHeader header = SerializationHeader.make(cfs.metadata(), Collections.emptyList());
-             StatsMetadata metadata = (StatsMetadata) new MetadataCollector(cfs.metadata().comparator)
-                                                      .sstableLevel(level)
-                                                      .finalizeMetadata(cfs.metadata().partitioner.getClass().getCanonicalName(), 0.01f, UNREPAIRED_SSTABLE, null, false, header)
-                                                      .get(MetadataType.STATS);
++            MetadataCollector collector = new MetadataCollector(cfs.metadata().comparator);
++            collector.update(new DeletionTime(timestamp, minLocalDeletionTime));
++            StatsMetadata metadata = (StatsMetadata) collector.sstableLevel(level)
++                                                              .finalizeMetadata(cfs.metadata().partitioner.getClass().getCanonicalName(), 0.01f, UNREPAIRED_SSTABLE, null, false, header)
++                                                              .get(MetadataType.STATS);
 +            SSTableReader reader = SSTableReader.internalOpen(descriptor, components, cfs.metadata,
 +                                                              fileHandle.sharedCopy(), fileHandle.sharedCopy(), indexSummary.sharedCopy(),
 +                                                              new AlwaysPresentFilter(), 1L, metadata, SSTableReader.OpenReason.NORMAL, header);
 +            reader.first = readerBounds(firstToken);
 +            reader.last = readerBounds(lastToken);
 +            if (!keepRef)
 +                reader.selfRef().release();
 +            return reader;
 +        }
 +
 +    }
 +
 +    public static ColumnFamilyStore newCFS()
 +    {
 +        return newCFS(ks.getName());
 +    }
 +
 +    public static ColumnFamilyStore newCFS(String ksname)
 +    {
 +        return newCFS(newTableMetadata(ksname));
 +    }
 +
 +    public static ColumnFamilyStore newCFS(Function<TableMetadata.Builder, TableMetadata.Builder> options)
 +    {
 +        return newCFS(ks.getName(), options);
 +    }
 +
 +    public static ColumnFamilyStore newCFS(String ksname, Function<TableMetadata.Builder, TableMetadata.Builder> options)
 +    {
 +        return newCFS(options.apply(newTableMetadataBuilder(ksname)).build());
 +    }
 +
 +    public static ColumnFamilyStore newCFS(TableMetadata metadata)
 +    {
 +        return new ColumnFamilyStore(ks, metadata.name, 0, new TableMetadataRef(metadata), new Directories(metadata), false, false, false);
 +    }
 +
 +    public static TableMetadata newTableMetadata(String ksname)
 +    {
 +        return newTableMetadata(ksname, "mockcf" + (id.incrementAndGet()));
 +    }
 +
 +    public static TableMetadata newTableMetadata(String ksname, String cfname)
 +    {
 +        return newTableMetadataBuilder(ksname, cfname).build();
 +    }
 +
 +    public static TableMetadata.Builder newTableMetadataBuilder(String ksname)
 +    {
 +        return newTableMetadataBuilder(ksname, "mockcf" + (id.incrementAndGet()));
 +    }
 +
 +    public static TableMetadata.Builder newTableMetadataBuilder(String ksname, String cfname)
 +    {
 +        return TableMetadata.builder(ksname, cfname)
 +                            .partitioner(Murmur3Partitioner.instance)
 +                            .addPartitionKeyColumn("key", UTF8Type.instance)
 +                            .addClusteringColumn("col", UTF8Type.instance)
 +                            .addRegularColumn("value", UTF8Type.instance)
 +                            .caching(CachingParams.CACHE_NOTHING);
 +    }
 +
 +    public static BufferDecoratedKey readerBounds(long generation)
 +    {
 +        return new BufferDecoratedKey(new Murmur3Partitioner.LongToken(generation), ByteBufferUtil.EMPTY_BYTE_BUFFER);
 +    }
 +
 +    private static File temp(String id)
 +    {
 +        File file = FileUtils.createTempFile(id, "tmp");
 +        file.deleteOnExit();
 +        return file;
 +    }
 +
 +    public static void cleanup()
 +    {
 +        // clean up data directory which are stored as data directory/keyspace/data files
 +        for (String dirName : DatabaseDescriptor.getAllDataFileLocations())
 +        {
 +            File dir = new File(dirName);
 +            if (!dir.exists())
 +                continue;
 +            String[] children = dir.list();
 +            for (String child : children)
 +                FileUtils.deleteRecursive(new File(dir, child));
 +        }
 +    }
 +}


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