Cassandra materialized view shows stale data

≡放荡痞女 提交于 2019-12-11 12:19:13

问题


I was trying out the Cassandra 3.0 alpha to see how materialized views work and following the example shown here.

The example works when a whole partition is deleted from the base table, but when I delete an individual clustered row, it continues to appear in the materialized view. Shouldn't a row deleted in the base table also disappear from the views?

For example:

CREATE TABLE base (part int, clus int , val int, PRIMARY KEY (part, clus));
CREATE MATERIALIZED VIEW view1 AS SELECT part FROM base WHERE part IS NOT NULL AND clus IS NOT NULL AND val IS NOT NULL PRIMARY KEY (val, part, clus);
INSERT INTO base (part, clus, val) VALUES ( 1, 2, 200 );
INSERT INTO base (part, clus, val) VALUES ( 1, 3, 300 );

SELECT * FROM view1;

 val | part | clus
-----+------+------
 200 |    1 |    2
 300 |    1 |    3

Then I delete just one of the rows:

DELETE FROM base WHERE part=1 and clus=3;

Now I was expecting val=300 to disappear from the view, but it didn't:

SELECT * FROM view1;

 val | part | clus
-----+------+------
 200 |    1 |    2
 300 |    1 |    3

Next if I delete the whole partition, the clustering row I deleted earlier is left behind in the view:

DELETE FROM base WHERE part=1;

SELECT * from base;

 clus | part | val
------+------+-----

SELECT * FROM view1;

 val | part | clus
-----+------+------
 300 |    1 |    3

I'm guessing this is a bug in the alpha release, but wanted to make sure this isn't the expected behavior. Should I be able to delete individual clustered rows and see that reflected in the materialized views?

I'm using this release:

nodetool version
ReleaseVersion: 3.0.0-alpha1-SNAPSHOT

Thanks.


回答1:


Both deletes and updates should be propagated to the view according to "Cassandra 3.0 materialised views in action".



来源:https://stackoverflow.com/questions/31810841/cassandra-materialized-view-shows-stale-data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!