Jim Meyer
Jim Meyer

Reputation: 9475

Cassandra materialized view shows stale data

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.

Upvotes: 1

Views: 1154

Answers (1)

Stefan Podkowinski
Stefan Podkowinski

Reputation: 5249

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

Upvotes: 1

Related Questions