Skip to content

Commit

Permalink
repair vtables should expose a completed field due to lack of filteri…
Browse files Browse the repository at this point in the history
…ng options in CQL

patch by David Capwell; reviewed by Chris Lohfink, Zhao Yang for CASSANDRA-17520
  • Loading branch information
dcapwell committed Apr 6, 2022
1 parent 885836b commit 828d98e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
4.1
* repair vtables should expose a completed field due to lack of filtering options in CQL (CASSANDRA-17520)
* remove outdated code from cqlsh (CASSANDRA-17490)
* remove support for deprecated version specific TLS in Python 3.6 (CASSANDRA-17365)
* Add support for IF EXISTS and IF NOT EXISTS in ALTER statements (CASSANDRA-16916)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ private static void addCompletableState(SimpleDataSet ds, Completable<?> state)
ds.column("failure_cause", state.getFailureCause());
ds.column("success_message", state.getSuccessMessage());
ds.column(timestampColumnName("init"), new Date(state.getInitializedAtMillis()));
ds.column("completed", result != null);

if (result != null)
ds.column(timestampColumnName(result.kind), new Date(state.getLastUpdatedAtMillis()));
Expand Down Expand Up @@ -479,6 +480,7 @@ private static String stdColumns(boolean time)
{
String str = " id timeuuid,\n" +
" last_updated_at timestamp,\n" +
" completed boolean,\n" +
" duration_millis bigint,\n" +
" failure_cause text,\n" +
" success_message text,\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public void repairs() throws Throwable
state.phase.start(tables, neighbors);
assertState("repairs", state, CoordinatorState.State.START);
List<List<String>> expectedRanges = neighbors.commonRanges.stream().map(a -> a.ranges.stream().map(Object::toString).collect(Collectors.toList())).collect(Collectors.toList());
assertRowsIgnoringOrder(execute(t("SELECT id, participants, table_names, ranges, unfiltered_ranges, participants FROM %s.repairs")),
row(state.id, ADDRESSES_STR, tables.stream().map(a -> a.name).collect(Collectors.toList()), expectedRanges, expectedRanges, neighbors.participants.stream().map(Object::toString).collect(Collectors.toList())));
assertRowsIgnoringOrder(execute(t("SELECT id, completed, participants, table_names, ranges, unfiltered_ranges, participants FROM %s.repairs")),
row(state.id, false, ADDRESSES_STR, tables.stream().map(a -> a.name).collect(Collectors.toList()), expectedRanges, expectedRanges, neighbors.participants.stream().map(Object::toString).collect(Collectors.toList())));

state.phase.prepareStart();
assertState("repairs", state, CoordinatorState.State.PREPARE_START);
Expand Down Expand Up @@ -187,8 +187,8 @@ public void participates() throws Throwable
state = participate();
assertInit("repair_participates", state);
state.phase.fail("testing");
assertRowsIgnoringOrder(execute(t("SELECT id, initiator, ranges, failure_cause, success_message, state_init_timestamp, state_success_timestamp, state_failure_timestamp FROM %s.repair_participates WHERE id = ?"), state.id),
row(state.getId(), FBUtilities.getBroadcastAddressAndPort().toString(), Arrays.asList("(0,42]"), "testing", null, new Date(state.getInitializedAtMillis()), null, new Date(state.getLastUpdatedAtMillis())));
assertRowsIgnoringOrder(execute(t("SELECT id, completed, initiator, ranges, failure_cause, success_message, state_init_timestamp, state_success_timestamp, state_failure_timestamp FROM %s.repair_participates WHERE id = ?"), state.id),
row(state.getId(), true, FBUtilities.getBroadcastAddressAndPort().toString(), Arrays.asList("(0,42]"), "testing", null, new Date(state.getInitializedAtMillis()), null, new Date(state.getLastUpdatedAtMillis())));

// make sure serialization works
execute(t("SELECT * FROM %s.repair_participates"));
Expand Down Expand Up @@ -246,14 +246,14 @@ private void assertInit(String table, State<?, ?> state) throws Throwable

private <T extends Enum<T>> void assertState(String table, State<?, ?> state, T expectedState) throws Throwable
{
assertRowsIgnoringOrder(execute(t("SELECT id, status, failure_cause, success_message FROM %s." + table + " WHERE id = ?"), state.getId()),
row(state.getId(), expectedState.name().toLowerCase(), null, null));
assertRowsIgnoringOrder(execute(t("SELECT id, completed, status, failure_cause, success_message FROM %s." + table + " WHERE id = ?"), state.getId()),
row(state.getId(), false, expectedState.name().toLowerCase(), null, null));
}

private void assertSuccess(String table, State<?, ?> state) throws Throwable
{
assertRowsIgnoringOrder(execute(t("SELECT id, status, failure_cause, success_message FROM %s." + table + " WHERE id = ?"), state.getId()),
row(state.getId(), "success", null, "testing"));
assertRowsIgnoringOrder(execute(t("SELECT id, completed, status, failure_cause, success_message FROM %s." + table + " WHERE id = ?"), state.getId()),
row(state.getId(), true, "success", null, "testing"));
}

private static ColumnFamilyStore table()
Expand Down

0 comments on commit 828d98e

Please sign in to comment.