diff --git a/CHANGES.txt b/CHANGES.txt index 60a349a982..f24bc10073 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -6,6 +6,7 @@ * Allow empty keystore_password in encryption_options (CASSANDRA-18778) * Skip ColumnFamilyStore#topPartitions initialization when client or tool mode (CASSANDRA-18697) Merged from 4.0: + * 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) diff --git a/src/java/org/apache/cassandra/repair/consistent/admin/PendingStats.java b/src/java/org/apache/cassandra/repair/consistent/admin/PendingStats.java index f1b515e666..fa7d5b5dd8 100644 --- a/src/java/org/apache/cassandra/repair/consistent/admin/PendingStats.java +++ b/src/java/org/apache/cassandra/repair/consistent/admin/PendingStats.java @@ -78,9 +78,10 @@ public class PendingStats Map 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); diff --git a/test/distributed/org/apache/cassandra/distributed/test/IncRepairAdminTest.java b/test/distributed/org/apache/cassandra/distributed/test/IncRepairAdminTest.java index b902632674..0156f36bf9 100644 --- a/test/distributed/org/apache/cassandra/distributed/test/IncRepairAdminTest.java +++ b/test/distributed/org/apache/cassandra/distributed/test/IncRepairAdminTest.java @@ -42,6 +42,7 @@ import org.apache.cassandra.service.ActiveRepairService; import org.apache.cassandra.streaming.PreviewKind; import org.apache.cassandra.utils.TimeUUID; +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; @@ -51,6 +52,27 @@ 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 {