question

jordanp98 avatar image
jordanp98 asked jordanp98 commented

Why is data in the base table but missing from the materialized view?

Please check below outputs for the information

As i can see keyspace_student has table student which has data but still related mview shows null results :

cassandra@cqlsh:keyspace_student> select * from student where roll_number='1234567890000';
 roll_number   | is_enable | biometric_id
---------------+-----------+---------------------
 1234567890000 | True      | 1095975000004044014

(1 rows)

cassandra@cqlsh:keyspace_student> SELECT * FROM view_student_by_biometric_id WHERE biometric_id = '1095975000004044014';
 biometric_id    | roll_number | is_enable
-----------------+-------------+-----------

When i tried dropping mview and recreating again it started working properly , how can i find the cause behind this ?

materialized views
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered jordanp98 commented

I've written about this topic a number of times over the years.

Materialized Views were added as a feature in Cassandra 3.0 (see blog post New in Cassandra 3.0: Materialized Views) to remove the burden from the application of having to keep tables in sync and instead off-load it server-side (CASSANDRA-6477). There are however issues with MVs since the task of updating the views with the base table is asynchronous. At some point when the views get so out-of-sync with the base table and the data can't be repaired, the only solution is to drop the problematic view and recreate it to force Cassandra to rebuild the view from scratch.

Due to issues with MVs, they have been reclassified as experimental with appropriate warnings for users who enable them so they at least are fully aware of its shortcomings should they decide to use this feature (CASSANDRA-13959).

For the record, there are lots of organisations who use materialized views in production and are using MVs successfully. The feature does work but if you run into out-of-sync issues, the only workaround available today is to drop and recreate the view. There are ongoing efforts to make MVs stable in C* 4.0 and future releases. Cheers!

1 comment Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

jordanp98 avatar image jordanp98 commented ·

Thanks For the the information.

0 Likes 0 ·