From 7b9428d8d7dc6d6cdff2e9d8a5e20879ff3b722e Mon Sep 17 00:00:00 2001 From: Nadav Har'El Date: Sun, 9 Nov 2025 21:25:01 +0200 Subject: [PATCH] test/cqlpy: test compression setting for auxiliary table In the previous patch we noticed that although recently (commit adf9c42, Refs #26610) we changed the default sstable compressor from LZ4Compressor to LZ4WithDictsCompressor, this change was only applied to CQL, not to Alternator. In this patch we add tests that demonstrate that it's even worse - the new compression only applies to CQL's *base* table - all the "auxiliary" tables - * Materialized views * Secondary index's materialized views * CDC log tables all still have the old LZ4Compressor, different from the base table's default compressor. The new test fails on Scylla, reproducing #26914, and passes on Cassandra (on Cassandra, we only compare the materialized view table, because SI and CDC is implemented differently). Signed-off-by: Nadav Har'El --- test/cqlpy/test_sstable_compression.py | 43 +++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/test/cqlpy/test_sstable_compression.py b/test/cqlpy/test_sstable_compression.py index 07242e5c40..a80696eb20 100644 --- a/test/cqlpy/test_sstable_compression.py +++ b/test/cqlpy/test_sstable_compression.py @@ -9,7 +9,7 @@ import pytest from . import nodetool -from .util import new_test_table +from .util import new_test_table, new_materialized_view, is_scylla from cassandra.protocol import ConfigurationException, SyntaxException # In older Cassandra and Scylla, the name of the compression algorithm was @@ -94,3 +94,44 @@ def test_huge_chunk_length(cql, test_keyspace, cassandra_bug): with new_test_table(cql, test_keyspace, "p int primary key, v int") as table: with pytest.raises(ConfigurationException, match='chunk_length_in_kb'): cql.execute("ALTER TABLE " + table + " with compression = { '" + sstable_compression + "': 'LZ4Compressor', 'chunk_length_in_kb': 1048576 }") + +# Check that whatever is currently the default sstable compression algorithm +# (for a long time it was LZ4Compressor but issue #26610 changed it to +# LZ4WithDictsCompressor), the base table and all its auxiliary tables - +# materialized view, secondary index and CDC log table - should use the same +# compression. We don't care if this happens because all these tables use +# the same default - or alternatively because the auxiliary tables "inherit" +# the configuration of the base table (#20388). Both are fine for this test. +# +# If the test runs on Cassandra, only the materialized view part of the test +# is done - the CDC and secondary index implementation on Cassandra is +# different and does not have an ordinary table backing it. +# Reproduces issue #26914 +@pytest.mark.xfail(reason='issue #26914') +def test_aux_tables_compression_parity(cql, test_keyspace): + extra = "with cdc = {'enabled': true}" if is_scylla(cql) else "" + with new_test_table(cql, test_keyspace, "p int primary key, v int", extra) as table: + with new_materialized_view(cql, table, '*', 'v, p', 'v is not null and p is not null') as mv: + cql.execute(f'CREATE INDEX ON {table}(v)') + # base table's compression setting: + ks, cf = table.split('.') + r = list(cql.execute(f"SELECT compression FROM system_schema.tables WHERE keyspace_name='{ks}' and table_name='{cf}'")) + assert len(r) == 1 + base_compression = r[0].compression + # view table's compression setting: + _, view = mv.split('.') + r = list(cql.execute(f"SELECT compression FROM system_schema.views WHERE keyspace_name='{ks}' and view_name='{view}'")) + assert len(r) == 1 + view_compression = r[0].compression + if extra: # Scylla-only part + # secondary index's backing view's compression setting: + r = list(cql.execute(f"SELECT compression FROM system_schema.views WHERE keyspace_name='{ks}' and view_name='{cf}_v_idx_index'")) + assert len(r) == 1 + index_compression = r[0].compression + assert view_compression == index_compression + # CDC log table's compression setting: + r = list(cql.execute(f"SELECT compression FROM system_schema.tables WHERE keyspace_name='{ks}' and table_name='{cf}_scylla_cdc_log'")) + assert len(r) == 1 + cdc_compression = r[0].compression + assert view_compression == cdc_compression + assert base_compression == view_compression