Skip to content

CASSANALYTICS-182 : CDC batch-write mixing a CDC-enabled and CDC-disabled table drops the CDC table's mutation#224

Merged
jyothsnakonisa merged 6 commits into
apache:trunkfrom
jyothsnakonisa:cdc-batch
Jul 23, 2026
Merged

CASSANALYTICS-182 : CDC batch-write mixing a CDC-enabled and CDC-disabled table drops the CDC table's mutation#224
jyothsnakonisa merged 6 commits into
apache:trunkfrom
jyothsnakonisa:cdc-batch

Conversation

@jyothsnakonisa

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread cassandra-analytics-cdc/src/main/java/org/apache/cassandra/cdc/Cdc.java Outdated
Comment thread cassandra-analytics-cdc/src/main/java/org/apache/cassandra/cdc/Cdc.java Outdated
@MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
public void testCqlTableCdcFlagSurvivesSerialization(CassandraBridge bridge)
{
// CqlTable.equals()/hashCode() deliberately exclude the cdc field (see CqlTable.java),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we have the cdc flag as part of our equality comparison and hashcode impl?

// table has cdc enabled already, update schema if it has changed
LOGGER.debug("CDC already enabled keyspace={} table={}", table.keyspace(), table.table());
// table already registered in Schema.instance — update if schema changed
LOGGER.debug("Table already in Schema.instance, updating if changed keyspace={} table={}", table.keyspace(), table.table());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this can noop presumably on a lot of cases, I think we should consider logging in the maybeUpdateSchema call in the case where we have an update. The prior logging here made sense as it was a dupe process; here it's just telling us that we already knew a table existed but not much else.

Preconditions.checkArgument(CassandraSchema.isCdcEnabled(schema, table),
"CDC not enabled for table: " + table.keyspace() + "." + table.table());
CassandraSchema.maybeUpdateSchema(schema, partitioner, table, tableId, table.cdc());
continue;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the if / continue structure (which is arguably glorified modern-day goto) instead of an if / else if / else structure?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This confused me. The name cdcEnabledTables followed by:

        cdcEnabledTables.forEach((ks, tables) -> tables.forEach(table -> {
            LOGGER.warn("Disabling CDC on table keyspace={} table={}", ks, table);
            CassandraSchema.disableCdc(schema, ks, table);
        }));

Read that we were removing cdcEnabledTables from our schema.

Renaming this variable to remainingCdcEnabledTables or schemaCdcEnabledTables plus a comment would help disambiguate this so it's clear we're not unregistering cdc enabled tables there at the end of the loop. The logic looks right but this naming threw me for a loop.

}
}

private static void unregisterTable(@NotNull Schema schema, @NotNull String keyspace, @NotNull String table)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should rename this. CassandraSchema#unregisterTable implies it's for just straight "unregistered your tables", vs. a name like CassandraSchema#unregisterNonCdcTables, which is where we see the "Refusing to unregistered CDC-enabled table" log message making a lot more sense.

@jmckenzie-dev jmckenzie-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some comment changes remaining but otherwise LGTM

Comment thread cassandra-analytics-cdc/src/main/java/org/apache/cassandra/cdc/Cdc.java Outdated
@jyothsnakonisa

Copy link
Copy Markdown
Contributor Author

@jmckenzie-dev jmckenzie-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks!

@jyothsnakonisa
jyothsnakonisa merged commit 839020f into apache:trunk Jul 23, 2026
99 of 104 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants