Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-14071

Materialized view on table with TTL issue

    XMLWordPrintableJSON

    Details

    • Severity:
      Normal
    • Since Version:

      Description

      Materialized views that cluster by a column that is not part of table's PK and are created from tables that have default_time_to_live seems to malfunction.

      Having this table

      CREATE TABLE sbutnariu.test_bug (
          field1 smallint,
          field2 smallint,
          date timestamp,
          PRIMARY KEY ((field1), field2)
      ) WITH default_time_to_live = 1000;
      

      and the materialized view

      CREATE MATERIALIZED VIEW sbutnariu.test_bug_by_date AS SELECT * FROM sbutnariu.test_bug WHERE field1 IS NOT NULL AND field2 IS NOT NULL AND date IS NOT NULL PRIMARY KEY ((field1), date, field2) WITH CLUSTERING ORDER BY (date desc, field2 asc);
      

      After inserting 3 rows with same PK (should upsert), the materialized view will have 3 rows.

      insert into sbutnariu.test_bug(field1, field2, date) values (1, 2, toTimestamp(now()));
      insert into sbutnariu.test_bug(field1, field2, date) values (1, 2, toTimestamp(now()));
      insert into sbutnariu.test_bug(field1, field2, date) values (1, 2, toTimestamp(now()));
      
      select * from sbutnariu.test_bug; /*1 row*/
      select * from sbutnariu.test_bug_by_date;/*3 rows*/
      

      If I remove the ttl and try again, it works as expected:

      truncate sbutnariu.test_bug;
      alter table sbutnariu.test_bug with default_time_to_live = 0;
      
      select * from sbutnariu.test_bug; /*1 row*/
      select * from sbutnariu.test_bug_by_date;/*1 row*/
      

      I've tested on versions 3.0.14 and 3.0.15. The bug was introduced in 3.0.15, as in 3.0.14 it works as expected.

        Attachments

        1. 14071-trunk-testall.png
          36 kB
          Paulo Motta (Deprecated)
        2. 14071-trunk-dtest.png
          66 kB
          Paulo Motta (Deprecated)
        3. 14071-3.11-testall.png
          44 kB
          Paulo Motta (Deprecated)
        4. 14071-3.11-dtest.png
          174 kB
          Paulo Motta (Deprecated)
        5. 14071-3.0-testall.png
          21 kB
          Paulo Motta (Deprecated)
        6. 14071-3.0-dtest.png
          64 kB
          Paulo Motta (Deprecated)

          Issue Links

            Activity

              People

              • Assignee:
                jasonstack Zhao Yang
                Reporter:
                sbutnariu Silviu Butnariu
                Authors:
                Zhao Yang
                Reviewers:
                Paulo Motta (Deprecated)
              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: