fix intermittent failures in nodetool toppartitions caused by failure to validate invalid bytes

Patch by Jordan West; Reviewed by Brandon Williams and Cheng Wang for CASSANDRA-17254
This commit is contained in:
Jordan West 2022-01-10 16:42:47 -08:00 committed by Jordan West
parent d9ef794ef6
commit 13d495aa7d
2 changed files with 8 additions and 5 deletions

View File

@ -1,5 +1,6 @@
3.0.29
* Fix running Ant rat targets without git (CASSANDRA-17974)
* Fix intermittent failure in nodetool toppartitions (CASSANDRA-17254)
3.0.28

View File

@ -1625,12 +1625,14 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
TabularDataSupport result = new TabularDataSupport(COUNTER_TYPE);
for (Counter<ByteBuffer> counter : samplerResults.topK)
{
byte[] key = counter.getItem().array();
//Not duplicating the buffer for safety because AbstractSerializer and ByteBufferUtil.bytesToHex
//don't modify position or limit
ByteBuffer key = counter.getItem();
result.put(new CompositeDataSupport(COUNTER_COMPOSITE_TYPE, COUNTER_NAMES, new Object[] {
Hex.bytesToHex(key), // raw
counter.getCount(), // count
counter.getError(), // error
metadata.getKeyValidator().getString(ByteBuffer.wrap(key)) })); // string
ByteBufferUtil.bytesToHex(key), // raw
counter.getCount(), // count
counter.getError(), // error
metadata.getKeyValidator().getString(key) })); // string
}
return new CompositeDataSupport(SAMPLING_RESULT, SAMPLER_NAMES, new Object[]{
samplerResults.cardinality, result});