|
18 | 18 |
|
19 | 19 | package org.apache.cassandra.distributed.test; |
20 | 20 |
|
| 21 | +import java.io.IOException; |
| 22 | +import java.util.Iterator; |
| 23 | + |
21 | 24 | import org.junit.Test; |
22 | 25 |
|
| 26 | +import org.apache.cassandra.db.Keyspace; |
23 | 27 | import org.apache.cassandra.distributed.Cluster; |
24 | 28 | import org.apache.cassandra.distributed.api.ConsistencyLevel; |
25 | 29 | import org.apache.cassandra.distributed.api.ICoordinator; |
| 30 | +import org.apache.cassandra.io.sstable.Descriptor; |
| 31 | +import org.apache.cassandra.io.sstable.format.SSTableReader; |
26 | 32 |
|
27 | 33 | import static org.apache.cassandra.distributed.api.Feature.GOSSIP; |
28 | 34 | import static org.apache.cassandra.distributed.api.Feature.NATIVE_PROTOCOL; |
@@ -75,4 +81,47 @@ private static void testUpdateCounter(boolean droppedCompactStorage) throws Thro |
75 | 81 | } |
76 | 82 | } |
77 | 83 | } |
| 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 | + } |
78 | 127 | } |
0 commit comments