Skip to content

Commit

Permalink
Merge branch 'cassandra-4.1' into trunk
Browse files Browse the repository at this point in the history
* cassandra-4.1:
  Fix the ordering of sstables when running sstableupgrade tool
  • Loading branch information
jacek-lewandowski committed Mar 14, 2023
2 parents 7ad746c + deb8abd commit d1ba381
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Merged from 4.0:
* Restore internode custom tracing on 4.0's new messaging system (CASSANDRA-17981)
Merged from 3.11:
Merged from 3.0:
* Fix the ordering of sstables when running sstableupgrade tool (CASSANDRA-18143)
* Fix default file system error handler for disk_failure_policy die (CASSANDRA-18294)
* Introduce check for names of test classes (CASSANDRA-17964)
* Suppress CVE-2022-41915 (CASSANDRA-18147)
Expand Down
13 changes: 13 additions & 0 deletions src/java/org/apache/cassandra/db/Directories.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.apache.cassandra.io.sstable.Descriptor;
import org.apache.cassandra.io.sstable.SSTable;
import org.apache.cassandra.io.sstable.SSTableId;
import org.apache.cassandra.io.sstable.SSTableIdFactory;
import org.apache.cassandra.io.util.File;
import org.apache.cassandra.io.util.FileStoreUtils;
import org.apache.cassandra.io.util.FileUtils;
Expand Down Expand Up @@ -974,6 +975,18 @@ public Map<Descriptor, Set<Component>> list()
return ImmutableMap.copyOf(components);
}

/**
* Returns a sorted version of the {@code list} method.
* Descriptors are sorted by generation.
* @return a List of descriptors to their components.
*/
public List<Map.Entry<Descriptor, Set<Component>>> sortedList()
{
List<Map.Entry<Descriptor, Set<Component>>> sortedEntries = new ArrayList<>(list().entrySet());
sortedEntries.sort((o1, o2) -> SSTableIdFactory.COMPARATOR.compare(o1.getKey().id, o2.getKey().id));
return sortedEntries;
}

public List<File> listFiles()
{
filter();
Expand Down
4 changes: 2 additions & 2 deletions src/java/org/apache/cassandra/tools/StandaloneUpgrader.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public static void main(String args[])

Collection<SSTableReader> readers = new ArrayList<>();

// Upgrade sstables
for (Map.Entry<Descriptor, Set<Component>> entry : lister.list().entrySet())
// Upgrade sstables in id order
for (Map.Entry<Descriptor, Set<Component>> entry : lister.sortedList())
{
Set<Component> components = entry.getValue();
if (!components.containsAll(entry.getKey().getFormat().primaryComponents()))
Expand Down

0 comments on commit d1ba381

Please sign in to comment.