Skip to content

Commit

Permalink
Fix nodetool repair_admin summarize-pending command to not throw exce…
Browse files Browse the repository at this point in the history
…ption

Fixed a bug causing the `OpenDataException` being thrown
when executing the `repair_admin summarize-pending` command.
This patch addresses the problem by including a missing composite
in `PendingStats.toComposite`, ensuring proper data conversion.

patch by Szymon Miezal; reviewed by Stefan Miklosovic and Brandon Williams for CASSANDRA-19014
  • Loading branch information
szymon-miezal authored and smiklosovic committed Nov 29, 2023
1 parent 0f2af6a commit 9affcf1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
@@ -1,4 +1,5 @@
4.0.12
* Fix nodetool repair_admin summarize-pending command to not throw exception (CASSANDRA-19014)
* Fix cassandra-stress in simplenative mode with prepared statements (CASSANDRA-18744)
* Fix filtering system ks sstables for relocation on startup (CASSANDRA-18963)
* Remove completed coordinator sessions (CASSANDRA-18903)
Expand Down
Expand Up @@ -78,9 +78,10 @@ public CompositeData toComposite()
Map<String, Object> values = new HashMap<>();
values.put(COMPOSITE_NAMES[0], keyspace);
values.put(COMPOSITE_NAMES[1], table);
values.put(COMPOSITE_NAMES[2], pending.toComposite());
values.put(COMPOSITE_NAMES[3], finalized.toComposite());
values.put(COMPOSITE_NAMES[4], failed.toComposite());
values.put(COMPOSITE_NAMES[2], total.toComposite());
values.put(COMPOSITE_NAMES[3], pending.toComposite());
values.put(COMPOSITE_NAMES[4], finalized.toComposite());
values.put(COMPOSITE_NAMES[5], failed.toComposite());
try
{
return new CompositeDataSupport(COMPOSITE_TYPE, values);
Expand Down
Expand Up @@ -43,13 +43,35 @@
import org.apache.cassandra.streaming.PreviewKind;
import org.apache.cassandra.utils.UUIDGen;

import static java.util.Arrays.stream;
import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
import static org.apache.cassandra.distributed.api.Feature.NETWORK;
import static org.apache.cassandra.repair.consistent.ConsistentSession.State.REPAIRING;
import static org.junit.Assert.assertTrue;

public class IncRepairAdminTest extends TestBaseImpl
{
@Test
public void testRepairAdminSummarizePending() throws IOException
{
try (Cluster cluster = init(Cluster.build(1)
.withConfig(config -> config.with(GOSSIP).with(NETWORK))
.start()))
{
// given a cluster with a table
cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (k INT PRIMARY KEY, v INT)");
// when running repair_admin summarize-pending
NodeToolResult res = cluster.get(1).nodetoolResult("repair_admin", "summarize-pending");
// then the table info should be present in the output
res.asserts().success();
String outputLine = stream(res.getStdout().split("\n"))
.filter(l -> l.contains(KEYSPACE) && l.contains("tbl"))
.findFirst()
.orElseThrow(() -> new AssertionError("should find tbl table in output of repair_admin summarize-pending"));
assertTrue("should contain information about zero pending bytes", outputLine.contains("0 bytes (0 sstables / 0 sessions)"));
}
}

@Test
public void testManualSessionFail() throws IOException
{
Expand Down

0 comments on commit 9affcf1

Please sign in to comment.