[
https://issues.apache.org/jira/browse/CASSANDRA-13657?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16075985#comment-16075985
]
Krishna Dattu Koneru commented on CASSANDRA-13657:
--------------------------------------------------
This happens because of how the row expiry works . Row exists as long as cells
(even non-pk) are live.
For example, below table (MV is also a table, just maintained by cassandra
automatically.)
{code}
CREATE TABLE t (k int, a int, b int, PRIMARY KEY (k,a));
insert into t (k,a) VALUES (1,1) using ttl 10;
update t using ttl 60 set b=1 where k=1 and a=1;
--- wait for 10 seconds.
select k,a,b,ttl(b) from t;
k | a | b | ttl(b)
---+---+---+--------
1 | 1 | 1 | 45
(1 rows)
{code}
Row does not expire as {{b}} is still alive.
This causes problem for materialized views.column from base table expires and
view row still exists. View row should expire because, base row will no longer
match the mandatory {{IS NOT NULL}} filter on PK columns.
I made a patch to make sure that non-primary key columns don't outlive view pk
columns.
||Patch||Circleci||
|[trunk|https://github.com/apache/cassandra/compare/trunk...krishna-koneru:CASSANDRA-13657-trunk]|[test|https://circleci.com/gh/krishna-koneru/cassandra/24]|
Comments appreciated.
( I am not sure if there is a way to fix already orphanized view entries )
> Materialized Views: Index MV on TTL'ed column produces orphanized view entry
> if another column keeps entry live
> ---------------------------------------------------------------------------------------------------------------
>
> Key: CASSANDRA-13657
> URL: https://issues.apache.org/jira/browse/CASSANDRA-13657
> Project: Cassandra
> Issue Type: Bug
> Components: Materialized Views
> Reporter: Fridtjof Sander
> Assignee: Krishna Dattu Koneru
>
> {noformat}
> CREATE TABLE t (k int, a int, b int, PRIMARY KEY (k));
> CREATE MATERIALIZED VIEW mv AS SELECT * FROM t WHERE k IS NOT NULL AND a IS
> NOT NULL PRIMARY KEY (a, k);
> INSERT INTO t (k) VALUES (1);
> UPDATE t USING TTL 5 SET a = 10 WHERE k = 1;
> UPDATE t SET b = 100 WHERE k = 1;
> SELECT * from t; SELECT * from mv;
> k | a | b
> ---+----+-----
> 1 | 10 | 100
> (1 rows)
> a | k | b
> ----+---+-----
> 10 | 1 | 100
> (1 rows)
> -- 5 seconds later
> SELECT * from t; SELECT * from mv;
> k | a | b
> ---+------+-----
> 1 | null | 100
> (1 rows)
> a | k | b
> ----+---+-----
> 10 | 1 | 100
> (1 rows)
> -- that view entry's liveness-info is (probably) dead, but the entry is kept
> alive by b=100
> DELETE b FROM t WHERE k=1;
> SELECT * from t; SELECT * from mv;
> k | a | b
> ---+------+------
> 1 | null | null
> (1 rows)
> a | k | b
> ----+---+-----
> 10 | 1 | 100
> (1 rows)
> DELETE FROM t WHERE k=1;
> cqlsh:test> SELECT * from t; SELECT * from mv;
> k | a | b
> ---+---+---
> (0 rows)
> a | k | b
> ----+---+-----
> 10 | 1 | 100
> (1 rows)
> -- deleting the base-entry doesn't help, because the view-key can not be
> constructed anymore (a=10 already expired)
> {noformat}
> The problem here is that although the view-entry's liveness-info (probably)
> expired correctly a regular column (`b`) keeps the view-entry live. It should
> have disappeared since it's indexed column (`a`) expired in the corresponding
> base-row. This is pretty severe, since that view-entry is now orphanized.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]