Skip to content

Add Cassandra 6.0 support - #236

Open
michaelsembwever wants to merge 1 commit into
apache:trunkfrom
thelastpickle:mck/37/trunk
Open

Add Cassandra 6.0 support#236
michaelsembwever wants to merge 1 commit into
apache:trunkfrom
thelastpickle:mck/37/trunk

Conversation

@michaelsembwever

Copy link
Copy Markdown
Member

https://issues.apache.org/jira/browse/CASSANALYTICS-37

Cassandra Analytics reads, bulk writes and consumes CDC through one bridge jar per major version. This adds the SIXZERO bridge, pinned to 6.0-alpha2 from Maven Central, in five new modules that copy and override the five-zero and four-zero sources.

Four 6.0 changes needed work:

  • SSTable versions big-pa and bti-ea, both added for compression dictionary metadata in the CompressionInfo component.
  • A trailing dictionary section in CompressionInfo. The six-zero CompressionMetadata deserializes it, interns one dictionary per dictId so that readers of one SSTable share the zstd compressor that ZstdDictionaryCompressor keys by dictId, and releases the references it holds through close(). SSTableCache gained a removal listener to call close(), and SSTableReader holds a second reference for the life of a stream.
  • CEP-21 Transactional Cluster Metadata retypes Schema.instance to SchemaProvider and replaces transform() with submit(), which notifies no listener offline, so SchemaUpdater initializes the keyspace instances by hand after ClusterMetadataService.initializeForClients().
  • Commit log version 9 and messaging version 14, read through the shaded 6.0 deserializers.

Two defects in the existing bridges surfaced while testing the copies and are fixed here. CassandraSchema.unregisterNonCdcTable called SchemaUpdater.load, which on 5.0 only adds a keyspace and throws AlreadyExistsException for one that exists, so the table stayed registered; removeTables replaces the keyspace metadata instead. On 5.0 that commit reaches Keyspace.dropCf, which needs machinery a client-mode process never started, so removeTables clears the initialized flag for the commit only.

BridgeVersionConsistencyTest asserts that every type a bridge hands out reports the bridge's own version, which catches a six-zero module that silently inherits a version-bearing class from five-zero through the Gradle copy-forward.

Cassandra Analytics reads, bulk writes and consumes CDC through one bridge jar per major version. This adds the SIXZERO bridge, pinned to 6.0-alpha2 from Maven Central, in five new modules that copy and override the five-zero and four-zero sources.

Four 6.0 changes needed work:

 - SSTable versions big-pa and bti-ea, both added for compression dictionary metadata in the CompressionInfo component.
 - A trailing dictionary section in CompressionInfo. The six-zero CompressionMetadata deserializes it, interns one dictionary per dictId so that readers of one SSTable share the zstd compressor that ZstdDictionaryCompressor keys by dictId, and releases the references it holds through close(). SSTableCache gained a removal listener to call close(), and SSTableReader holds a second reference for the life of a stream.
 - CEP-21 Transactional Cluster Metadata retypes Schema.instance to SchemaProvider and replaces transform() with submit(), which notifies no listener offline, so SchemaUpdater initializes the keyspace instances by hand after ClusterMetadataService.initializeForClients().
 - Commit log version 9 and messaging version 14, read through the shaded 6.0 deserializers.

Two defects in the existing bridges surfaced while testing the copies and are fixed here. CassandraSchema.unregisterNonCdcTable called SchemaUpdater.load, which on 5.0 only adds a keyspace and throws AlreadyExistsException for one that exists, so the table stayed registered; removeTables replaces the keyspace metadata instead. On 5.0 that commit reaches Keyspace.dropCf, which needs machinery a client-mode process never started, so removeTables clears the initialized flag for the commit only.

BridgeVersionConsistencyTest asserts that every type a bridge hands out reports the bridge's own version, which catches a six-zero module that silently inherits a version-bearing class from five-zero through the Gradle copy-forward.

 patch by Mick Semb Wever; reviewed by xxx for CASSANALYTICS-37

Assisted-By: Claude Opus 5 <noreply@anthropic.com>

@sarankk sarankk 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.

Thanks for this Mick! changes look good to me, left for few comments

Consumer<Writer> consumer)
{
File cassFile = new File(directory.toFile());
try (SSTableTombstoneWriter writer = SSTableTombstoneWriter.builder()

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.

Shall we use CQLSSTableWriter here, since 6.0 version's CQLSSTableWriter takes any modification statement. Changes in SSTableTombstoneWriter are very similar to one in CQLSSTableWriter. Also with this, we can remove SSTableTombstoneWriter in 6.0 bridge.

{
return partitioner.toLowerCase().contains("random")
? RandomPartitioner.instance
: Murmur3Partitioner.instance;

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.

Murmur3Partitioner.instance variable seems to be available in 4.0 version as well. Shall we update this in 4.0 bridge and remove the class override here.

/**
* Unit tests for configuring {@link SSTableWriterImplementation}
*/
class SSTableWriterImplementationTest

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.

We can remove this test class as well if we update in 4.0 version

Comment on lines +119 to +120
rowBuilder.addCell(CqlType.expiring(cd, timestamp, ttl, now, type().serialize(o),
CellPath.create(TimeUUID.Generator.nextTimeUUID().toBytes())));

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.

How about we use randomCellPath() instead in 4.0 types module? we can remove override in 6.0 types

Suggested change
rowBuilder.addCell(CqlType.expiring(cd, timestamp, ttl, now, type().serialize(o),
CellPath.create(TimeUUID.Generator.nextTimeUUID().toBytes())));
rowBuilder.addCell(CqlType.expiring(cd, timestamp, ttl, now, type().serialize(o), randomCellPath()));

import org.apache.cassandra.utils.TimeUUID;

/**
* A copy of the four-zero class. Cassandra 5.0 removed {@code UUIDGen.getTimeUUID()}, so the inherited

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.

TimeUUID in 5.0 types already overrides randomValue method, we can remove this class in 6.0

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