Skip to content

Commit 1c5286f

Browse files
Dmitry Konstantinovsmiklosovic
authored andcommitted
Fix IndexOutOfBoundsException in sstablemetadata tool when a range tombstone is a max clustering value
patch by Dmitry Konstantinov; reviewed by Stefan Miklosovic for CASSANDRA-20855
1 parent f9dbfd4 commit 1c5286f

File tree

11 files changed

+83
-15
lines changed

11 files changed

+83
-15
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
4.0.19
2+
* Fix IndexOutOfBoundsException in sstablemetadata tool when a range tombstone is a max clustering value (CASSANDRA-20855)
23
* Update Jackson to 2.19.2 (CASSANDRA-20848)
34
* Update commons-lang3 to 3.18.0 (CASSANDRA-20849)
45
* Add NativeTransportMaxConcurrentConnectionsPerIp to StorageProxyMBean (CASSANDRA-20642)

src/java/org/apache/cassandra/tools/SSTableMetadataViewer.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -355,21 +355,9 @@ private void printSStableMetadata(String fname, boolean scan) throws IOException
355355
if (validation != null && header != null)
356356
printMinMaxToken(descriptor, FBUtilities.newPartitioner(descriptor), header.getKeyType());
357357

358-
if (header != null && header.getClusteringTypes().size() == stats.minClusteringValues.size())
359-
{
360-
List<AbstractType<?>> clusteringTypes = header.getClusteringTypes();
361-
List<ByteBuffer> minClusteringValues = stats.minClusteringValues;
362-
List<ByteBuffer> maxClusteringValues = stats.maxClusteringValues;
363-
String[] minValues = new String[clusteringTypes.size()];
364-
String[] maxValues = new String[clusteringTypes.size()];
365-
for (int i = 0; i < clusteringTypes.size(); i++)
366-
{
367-
minValues[i] = clusteringTypes.get(i).getString(minClusteringValues.get(i));
368-
maxValues[i] = clusteringTypes.get(i).getString(maxClusteringValues.get(i));
369-
}
370-
field("minClusteringValues", Arrays.toString(minValues));
371-
field("maxClusteringValues", Arrays.toString(maxValues));
372-
}
358+
printClusteringValues(header, "minClusteringValues", stats.minClusteringValues);
359+
printClusteringValues(header, "maxClusteringValues", stats.maxClusteringValues);
360+
373361
field("Estimated droppable tombstones",
374362
stats.getEstimatedDroppableTombstoneRatio((int) (System.currentTimeMillis() / 1000) - this.gc));
375363
field("SSTable Level", stats.sstableLevel);
@@ -436,6 +424,21 @@ private void printSStableMetadata(String fname, boolean scan) throws IOException
436424
}
437425
}
438426

427+
private void printClusteringValues(SerializationHeader.Component header, String name, List<ByteBuffer> clusteringValues)
428+
{
429+
if (header != null && header.getClusteringTypes().size() >= clusteringValues.size())
430+
{
431+
List<AbstractType<?>> clusteringTypes = header.getClusteringTypes();
432+
int size = Math.min(clusteringTypes.size(), clusteringValues.size());
433+
String[] values = new String[size];
434+
for (int i = 0; i < size; i++)
435+
{
436+
values[i] = clusteringTypes.get(i).getString(clusteringValues.get(i));
437+
}
438+
field(name, Arrays.toString(values));
439+
}
440+
}
441+
439442
private void field(String field, Object value)
440443
{
441444
field(field, value, null);
47 Bytes
Binary file not shown.
83 Bytes
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3617993137
16 Bytes
Binary file not shown.
14 Bytes
Binary file not shown.
4.74 KB
Binary file not shown.
74 Bytes
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Data.db
2+
TOC.txt
3+
Digest.crc32
4+
Summary.db
5+
Filter.db
6+
Statistics.db
7+
CompressionInfo.db
8+
Index.db

0 commit comments

Comments
 (0)