Skip to content

Commit

Permalink
DBZ-7363 Debezium stops producing events on schema changes in cassandra4
Browse files Browse the repository at this point in the history
Adjust cassandra4 schema listener to use old table metadata Table ID
when replacing the metadata in Cassandra 4 Schema Provider. Replace
current logic of calculating the uuid from keyspace name and table name
which does not match.
  • Loading branch information
schampilomatis committed Jan 18, 2024
1 parent 207b0ad commit f9b6791
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.cassandra.schema.TableId;
import org.apache.cassandra.schema.TableMetadata;
import org.apache.cassandra.schema.TableMetadataRef;
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -243,13 +242,10 @@ else if (oldCdc) {
newCdc);
// else if it was not cdc before nor now, do nothing with schema holder
// but add it to Cassandra for subsequent deserialization path in every case

UUID uuid = UUID.nameUUIDFromBytes(ArrayUtils.addAll(newTableMetadata.getKeyspace().toString().getBytes(),
newTableMetadata.getName().toString().getBytes()));

// we need to use the id of the existing table to correctly replace it
org.apache.cassandra.schema.TableMetadata metadata = CreateTableStatement.parse(newTableMetadata.describe(true),
newTableMetadata.getKeyspace().toString())
.id(TableId.fromUUID(uuid))
.id(TableId.fromUUID(oldTableMetaData.getId().get()))
.build();

org.apache.cassandra.schema.KeyspaceMetadata current = Schema.instance.getKeyspaceMetadata(metadata.keyspace);
Expand Down

0 comments on commit f9b6791

Please sign in to comment.