Skip to content

Commit 2b5124d

Browse files
committed
Merge branch 'cassandra-5.0' into trunk
2 parents a7a85c6 + d17e6d1 commit 2b5124d

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ Merged from 4.1:
354354
* Enforce CQL message size limit on multiframe messages (CASSANDRA-20052)
355355
* Fix race condition in DecayingEstimatedHistogramReservoir during rescale (CASSANDRA-19365)
356356
Merged from 4.0:
357+
* ArrayIndexOutOfBoundsException with repaired data tracking and counters (CASSANDRA-20871)
357358
* Fix cleanup of old incremental repair sessions in case of owned token range changes or a table deleting (CASSANDRA-20877)
358359
* Fix memory leak in BufferPoolAllocator when a capacity needs to be extended (CASSANDRA-20753)
359360
* Leveled Compaction doesn't validate maxBytesForLevel when the table is altered/created (CASSANDRA-20570)

src/java/org/apache/cassandra/db/Digest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ public <V> Digest updateWithCounterContext(V context, ValueAccessor<V> accessor)
6969
// for the purposes of repaired data tracking on the read path, exclude
7070
// contexts with legacy shards as these may be irrevocably different on
7171
// different replicas
72+
73+
// see super.updateWithCounterContext + CountersTest.testEmptyContext - counter context can be empty
74+
if (accessor.isEmpty(context))
75+
return this;
76+
7277
if (CounterContext.instance().hasLegacyShards(context, accessor))
7378
return this;
7479

test/distributed/org/apache/cassandra/distributed/test/CountersTest.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@
1818

1919
package org.apache.cassandra.distributed.test;
2020

21+
import java.io.IOException;
22+
import java.util.Iterator;
23+
2124
import org.junit.Test;
2225

26+
import org.apache.cassandra.db.Keyspace;
2327
import org.apache.cassandra.distributed.Cluster;
2428
import org.apache.cassandra.distributed.api.ConsistencyLevel;
2529
import org.apache.cassandra.distributed.api.ICoordinator;
30+
import org.apache.cassandra.io.sstable.Descriptor;
31+
import org.apache.cassandra.io.sstable.format.SSTableReader;
2632

2733
import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
2834
import static org.apache.cassandra.distributed.api.Feature.NATIVE_PROTOCOL;
@@ -75,4 +81,47 @@ private static void testUpdateCounter(boolean droppedCompactStorage) throws Thro
7581
}
7682
}
7783
}
84+
85+
@Test
86+
public void testEmptyContext() throws IOException
87+
{
88+
try (Cluster cluster = init(Cluster.build(3)
89+
.withConfig(c -> c.with(GOSSIP, NATIVE_PROTOCOL)
90+
.set("repaired_data_tracking_for_partition_reads_enabled", true)
91+
.set("repaired_data_tracking_for_range_reads_enabled", true))
92+
.start()))
93+
{
94+
cluster.schemaChange(withKeyspace("CREATE TABLE %s.t (a ascii, b ascii, c counter, d counter, PRIMARY KEY(a, b))"));
95+
cluster.get(1).executeInternal(withKeyspace("UPDATE %s.t SET c = c + 1, d = d + 1 WHERE a = 'a1' AND b = 'b1'"));
96+
cluster.get(2).executeInternal(withKeyspace("UPDATE %s.t SET c = c + 2, d = d + 2 WHERE a = 'a1' AND b = 'b1'"));
97+
cluster.get(3).executeInternal(withKeyspace("UPDATE %s.t SET c = c + 3, d = d + 3 WHERE a = 'a1' AND b = 'b1'"));
98+
99+
cluster.forEach(i -> i.flush(KEYSPACE));
100+
101+
cluster.forEach(i -> i.runOnInstance(() -> {
102+
Iterator<SSTableReader> sstables = Keyspace.open(KEYSPACE)
103+
.getColumnFamilyStore("t")
104+
.getLiveSSTables()
105+
.iterator();
106+
while (sstables.hasNext())
107+
{
108+
SSTableReader sstable = sstables.next();
109+
Descriptor descriptor = sstable.descriptor;
110+
try
111+
{
112+
descriptor.getMetadataSerializer()
113+
.mutateRepairMetadata(descriptor, System.currentTimeMillis(), null, false);
114+
sstable.reloadSSTableMetadata();
115+
}
116+
catch (IOException e)
117+
{
118+
throw new RuntimeException(e);
119+
}
120+
}
121+
}));
122+
cluster.coordinator(1).execute(withKeyspace("select a,d from %s.t where a = 'a1'"), ConsistencyLevel.ALL);
123+
cluster.coordinator(2).execute(withKeyspace("select a,d from %s.t where a = 'a1'"), ConsistencyLevel.QUORUM);
124+
cluster.coordinator(3).execute(withKeyspace("select a,d from %s.t where a = 'a1'"), ConsistencyLevel.QUORUM);
125+
}
126+
}
78127
}

0 commit comments

Comments
 (0)