Files
scylladb/test/cql/cdc_enable_disable_test.cql
Kamil Braun 72f629c2b6 test: cdc_enable_disable_test: remove non-determinism
The test sometimes fails because the order of rows in the SELECT results
depends on how stream IDs for the different partition keys get generated.
In some runs the stream ID for pk=1 may go before the stream ID for
pk=4, in some runs the other way.

The fix is to use the same partition key but different clustering keys
for the different rows.

Refs: #10601

Closes #10718
2022-06-02 19:40:07 +03:00

55 lines
1.8 KiB
SQL

-- Important: using the same partition key for each row so the results of select from log table
-- do not depend on how stream IDs are assigned to partition keys.
-- Error messages contain a keyspace name. Make the output stable.
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
-- create cdc enabled table
create table ks.t (pk int, ck int, v int, primary key(pk, ck)) with cdc = {'enabled': true};
-- this write goes to the log
insert into ks.t (pk, ck, v) values (0, 1, 100);
-- disable cdc. should retain the log
alter table ks.t with cdc = {'enabled': false};
-- add more data to base - should not generate log
insert into ks.t (pk, ck, v) values (0, 2, 200);
-- should still work, and give one row (0, 1, 100)
select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, v from ks.t_scylla_cdc_log;
-- lets add a column
alter table ks.t add v2 text;
-- add more data
insert into ks.t (pk, ck, v, v2) values (0, 3, 300, 'apa');
-- turn cdc back on
alter table ks.t with cdc = {'enabled': true};
-- more data - this should also go to log.
insert into ks.t (pk, ck, v, v2) values (0, 4, 400, 'snus');
-- gives two rows (0, 1, 100)+(0, 4, 400, 'snus')
select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, v, v2 from ks.t_scylla_cdc_log;
-- disable cdc. should retain the log
alter table ks.t with cdc = {'enabled': false};
-- remove older column
alter table ks.t drop v;
-- add more data
insert into ks.t (pk, ck, v2) values (0, 5, 'fisk');
-- turn cdc back on
alter table ks.t with cdc = {'enabled': true};
insert into ks.t (pk, ck, v2) values (0, 6, 'aborre');
-- gives three rows (0, 1)+(0, 4, 'snus')+(0, 6, 'aborre')
select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, v2 from ks.t_scylla_cdc_log;
DROP KEYSPACE ks;