New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a column to the base table should invalidate prepared statements for views #16392
Comments
This sounds quite severe, no? I think it should be prioritized. @nyh - any rough estimates on the complexity of a fix for this? |
@nyh I understand the issue is visable when creating a MV with "SELECT *" and using "SELECT *" from MV. This remind me of https://stackoverflow.com/questions/3639861/why-is-select-considered-harmful |
@nyh - ping - do we have any thoughts on this? Just an estimate would be great - assigning it to you (temporarily) for consideration. |
As I said I just quoted @tgrabiec's statement about this being a bug - I didn't reproduce it myself and I don't know, if this bug exists, how severe it is. I'm not really an expert in prepared statement invalidation and why was important to have it for non-views - I assume the same reasons why we need prepared-statement-invalidation would apply to views (@mykaul maybe you know who the expert on this might be). |
@eliransin - is the above in your team? Who can look at this? |
First step IMO is to reproduce the issue (if even exists):
Will make an attempt on this. |
Reproduced with cql-pytest:
This fails with:
Working on a fix |
This bug was discovered as part of another bug investigation, if the base table changes, for example a row is added or removed, the prepared statements of the materialized views doesn't change, this will result in returning incomplete information until the prepared statements cache is invalidated for some other reason or until the node is rebooted. This patch fixes it by accounting for the fact that a materialized view select query also depends on it's base table. Fixes scylladb#16392 Signed-off-by: Eliran Sinvani <eliransin@scylladb.com>
Issue scylladb#16392 describes a bug where when a base table is altered, it's materialized views prepared statements are not invalidated which in turn causes them to return missing data. This test reproduces this bug and serves as a regression test for this problem. Signed-off-by: Eliran Sinvani <eliransin@scylladb.com>
Fix submitted 🙂 |
@nyh had very good questions about why didn't this happen automatically and I think he is right. This fix in #16830 will work. However, it is not the correct point for fixing this so I will try to figure it out using the correct point this time. |
Issue scylladb#16392 describes a bug where when a base table is altered, it's materialized views prepared statements are not invalidated which in turn causes them to return missing data. This test reproduces this bug and serves as a regression test for this problem. Signed-off-by: Eliran Sinvani <eliransin@scylladb.com>
When a base table changes and altered, so does the views that might refer to the added column (which includes "SELECT *" views and also views that might need to use this column for rows lifetime (virtual columns). However the query processor implementation for views change notification was an empty function. Since views are tables, the query processor needs to at least treat them as such (and maybe in the future, do also some MV specific stuff). This commit adds a call to `on_update_column_family` from within `on_update_view`. The side effect true to this date is that prepared statements for views which changed due to a base table change will be invalidated. Fixes scylladb#16392 Signed-off-by: Eliran Sinvani <eliransin@scylladb.com>
Issue scylladb#16392 describes a bug where when a base table is altered, it's materialized views prepared statements are not invalidated which in turn causes them to return missing data. This test reproduces this bug and serves as a regression test for this problem. Signed-off-by: Eliran Sinvani <eliransin@scylladb.com>
…nges.' from Eliran Sinvani When a base table changes and altered, so does the views that might refer to the added column (which includes "SELECT *" views and also views that might need to use this column for rows lifetime (virtual columns). However the query processor implementation for views change notification was an empty function. Since views are tables, the query processor needs to at least treat them as such (and maybe in the future, do also some MV specific stuff). This commit adds a call to `on_update_column_family` from within `on_update_view`. The side effect true to this date is that prepared statements for views which changed due to a base table change will be invalidated. Fixes #16392 This series also adds a test which fails without this fix and passes when the fix is applied. Closes #16897 * github.com:scylladb/scylladb: Add test for mv prepared statements invalidation on base alter query processor: treat view changes at least as table changes
This bug exists since very long ago, so all live versions needs a backport 🙂 (I checked 5.1 and above). |
@scylladb/scylla-maint please backport |
I'll do it now. |
…nges.' from Eliran Sinvani When a base table changes and altered, so does the views that might refer to the added column (which includes "SELECT *" views and also views that might need to use this column for rows lifetime (virtual columns). However the query processor implementation for views change notification was an empty function. Since views are tables, the query processor needs to at least treat them as such (and maybe in the future, do also some MV specific stuff). This commit adds a call to `on_update_column_family` from within `on_update_view`. The side effect true to this date is that prepared statements for views which changed due to a base table change will be invalidated. Fixes #16392 This series also adds a test which fails without this fix and passes when the fix is applied. Closes #16897 * github.com:scylladb/scylladb: Add test for mv prepared statements invalidation on base alter query processor: treat view changes at least as table changes (cherry picked from commit 5810396)
…nges.' from Eliran Sinvani When a base table changes and altered, so does the views that might refer to the added column (which includes "SELECT *" views and also views that might need to use this column for rows lifetime (virtual columns). However the query processor implementation for views change notification was an empty function. Since views are tables, the query processor needs to at least treat them as such (and maybe in the future, do also some MV specific stuff). This commit adds a call to `on_update_column_family` from within `on_update_view`. The side effect true to this date is that prepared statements for views which changed due to a base table change will be invalidated. Fixes #16392 This series also adds a test which fails without this fix and passes when the fix is applied. Closes #16897 * github.com:scylladb/scylladb: Add test for mv prepared statements invalidation on base alter query processor: treat view changes at least as table changes (cherry picked from commit 5810396)
When a base table changes and altered, so does the views that might refer to the added column (which includes "SELECT *" views and also views that might need to use this column for rows lifetime (virtual columns). However the query processor implementation for views change notification was an empty function. Since views are tables, the query processor needs to at least treat them as such (and maybe in the future, do also some MV specific stuff). This commit adds a call to `on_update_column_family` from within `on_update_view`. The side effect true to this date is that prepared statements for views which changed due to a base table change will be invalidated. Fixes scylladb#16392 Signed-off-by: Eliran Sinvani <eliransin@scylladb.com>
Issue scylladb#16392 describes a bug where when a base table is altered, it's materialized views prepared statements are not invalidated which in turn causes them to return missing data. This test reproduces this bug and serves as a regression test for this problem. Signed-off-by: Eliran Sinvani <eliransin@scylladb.com>
In https://github.com/scylladb/scylla-enterprise/issues/3493#issuecomment-1850936534, @tgrabiec noticed that:
"I've noticed that adding a column to the base table does not invalidate prepared statements for the views. So select * query doesn't see the new column. Only after scylla restarts queries start to see it. So it can happen that depending on which host you contact, you may see the new column or not."
The text was updated successfully, but these errors were encountered: