-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
roachtest/sqlsmith: internal error: executing declarative schema change: index ID 1 found in depended-on-by references, no such index in this relation #108974
Comments
a smaller repo:
The issue is that the UDF body forces the query to use the primary index of In contrast, if we were to use legacy schema changer, which rewrite the primary index in-place, the This has made me wonder "what should be the right behavior?" My initial thoughts are "ah, okay, let me disallow this case for declarative schema changer then!" but that will create behavioral divergence between legacy and declarative schema changer. It's a bit unfortunate that the way we track back-references from tables to UDFs uses index IDs so that our two schema changer implementation differences would leak and cause a SQL difference. @fqazi and @rafiss I'd like to hear your thoughts on this. |
The right answer here is we need to be able to rewrite back-references since the builder should be able to detect the function dependency and update it for the new index (i.e. drop and recreate it with the new index ID). We can block this operation can fallback for the declarative schema changer in the short term. |
@fqazi I thin what you suggested is dangerous. Consider a function
this will create two identical back-references in the table
What you suggested is to, in the builder, look at back-references and schedule rewrites such that those back-references be updated to new index ID. But that will break the UDF since I had a chat with @mgartner yesterday and learned that in PG users bear the risk of breaking the UDF if they change the referencing tables (PG won't prevent them from modifying the table in a udf-breaking way), but so far in CRDB we have tried to track the dependencies and disallow schema changes to tables that would break UDFs that reference them. For now, I will teach the declarative schema changer to detect this case and fallback to legacy schema changer |
I think it could be argued both of those are the same, you are pointing to the same object (index). I think, at least from a usability perspective, we probably should aim for better since dangling references are just bad. Like its okay to aim for PG compatibility in general, but if a behaviour is suspicious or bad, we should have some leeway. That's just my opinion on it. |
I agree that we don't want to copy every single bit of PG's behavior. I am saying that if we were to update the back-reference in the table, we would need to potentially update/rewrite the UDF too (e.g. change |
Another note: for This means schema changes that will actually drop the old primary index will be broken in the legacy schema changer. For example, off my head, that will be
The ALTER PK will hang with logs like
This makes me think maybe we should alter both schema changers to reject such schema changes. |
The answer is maybe...but I'm sure @rafiss has thoughts on it, too. This is probably the longer-term answer, I think.
It also makes me think of chicken and egg problems here...i.e. you can't replace the routine to refer to the new index, without having the new index. |
Hit this when running slightly adjusted
roachtest/sqlsmith
(which includes #108972) manually:The way to reproduce is
sqlsmith.zip
(it's likely this can be significantly reduced - I didn't try.)
Note that it seems to be a regression on master given that this doesn't repro on 23.1.7.
Jira issue: CRDB-30725
The text was updated successfully, but these errors were encountered: