diff --git a/CHANGES.txt b/CHANGES.txt index ffeeb2932a..b66a1f69f5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -278,6 +278,7 @@ * RateBasedBackPressure unnecessarily invokes a lock on the Guava RateLimiter (CASSANDRA-14163) * Fix wildcard GROUP BY queries (CASSANDRA-14209) Merged from 3.0: + * Fix corrupted static collection deletions in 3.0 -> 2.{1,2} messages (CASSANDRA-14568) * Fix potential IndexOutOfBoundsException with counters (CASSANDRA-14167) * Always close RT markers returned by ReadCommand#executeLocally() (CASSANDRA-14515) * Reverse order queries with range tombstones can cause data loss (CASSANDRA-14513) diff --git a/src/java/org/apache/cassandra/db/partitions/PartitionUpdate.java b/src/java/org/apache/cassandra/db/partitions/PartitionUpdate.java index 2dc566a83c..b7934202d7 100644 --- a/src/java/org/apache/cassandra/db/partitions/PartitionUpdate.java +++ b/src/java/org/apache/cassandra/db/partitions/PartitionUpdate.java @@ -118,23 +118,39 @@ public class PartitionUpdate extends AbstractBTreePartition * * @param metadata the metadata for the created update. * @param key the partition key for the partition to update. - * @param row the row for the update. + * @param row the row for the update (may be null). + * @param row the static row for the update (may be null). + * + * @return the newly created partition update containing only {@code row}. + */ + public static PartitionUpdate singleRowUpdate(TableMetadata metadata, DecoratedKey key, Row row, Row staticRow) + { + MutableDeletionInfo deletionInfo = MutableDeletionInfo.live(); + Holder holder = new Holder( + new RegularAndStaticColumns( + staticRow == null ? Columns.NONE : Columns.from(staticRow.columns()), + row == null ? Columns.NONE : Columns.from(row.columns()) + ), + row == null ? BTree.empty() : BTree.singleton(row), + deletionInfo, + staticRow == null ? Rows.EMPTY_STATIC_ROW : staticRow, + EncodingStats.NO_STATS + ); + return new PartitionUpdate(metadata, key, holder, deletionInfo, false); + } + + /** + * Creates an immutable partition update that contains a single row update. + * + * @param metadata the metadata for the created update. + * @param key the partition key for the partition to update. + * @param row the row for the update (may be static). * * @return the newly created partition update containing only {@code row}. */ public static PartitionUpdate singleRowUpdate(TableMetadata metadata, DecoratedKey key, Row row) { - MutableDeletionInfo deletionInfo = MutableDeletionInfo.live(); - if (row.isStatic()) - { - Holder holder = new Holder(new RegularAndStaticColumns(Columns.from(row.columns()), Columns.NONE), BTree.empty(), deletionInfo, row, EncodingStats.NO_STATS); - return new PartitionUpdate(metadata, key, holder, deletionInfo, false); - } - else - { - Holder holder = new Holder(new RegularAndStaticColumns(Columns.NONE, Columns.from(row.columns())), BTree.singleton(row), deletionInfo, Rows.EMPTY_STATIC_ROW, EncodingStats.NO_STATS); - return new PartitionUpdate(metadata, key, holder, deletionInfo, false); - } + return singleRowUpdate(metadata, key, row.isStatic() ? null : row, row.isStatic() ? row : null); } /**