-
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
sql: bug when setting a column NOT NULL and then dropping it #47719
Comments
This would be fixed with the approach outlined in #47989 (comment). |
It turns out this is much more severe if the DROP COLUMN is concurrent but in a different transaction and thus has a different mutation ID. |
@fqazi see #61500 (comment). I think we can do something about this without too too much effort. Namely I think we want to skip over some set of mutations which are made irrelevant by some set of later mutations. Specifically I'm thinking about constraints like not null and check that have to do with a now dropped column. It's possible that we should just straight up drop those mutations when we're dropping the column. Then, we can augment that by being a bit more careful about the code that relies on those mutations existing. All of this is unsatisfying but I think these bugs are worth doing something about even if it's only for the short term. We'll want to backport whatever we do here I suspect. |
Fixes: cockroachdb#47719 Previously, if a column was mutated and then dropped in a single transaction we would still try to validate the dropped column. Additionally, in general if a drop operation occurred in a different transaction we ran the danger of doing something similar. From a behaviour perspective this was bad, since it can lead to unexpected behaviour for users. To address, this patch introduces logic to scan later mutations to check if a drop column occurs. If one does occur then it will skip any operations made irrelevant by the drop. Additionally, for a correctness perspective it will wait for the drop to complete before returning back. Release note (bug fix): A constraint like not null or check on a column made irrelevant by a drop in a later concurrent transaction would lead to incorrect errors / behaviour.
Fixes: cockroachdb#47719 Previously, if a column was mutated and then dropped in a single transaction we would still try to validate the dropped column. Additionally, in general if a drop operation occurred in a different transaction we ran the danger of doing something similar. From a behaviour perspective this was bad, since it can lead to unexpected behaviour for users. To address, this patch introduces logic to scan later mutations to check if a drop column occurs. If one does occur then it will skip any operations made irrelevant by the drop. Additionally, for a correctness perspective it will wait for the drop to complete before returning back. Release note (bug fix): A constraint like not null or check on a column made irrelevant by a drop in a later concurrent transaction would lead to incorrect errors / behaviour.
62076: sql: add interleaved_indexes/interleaved_tables into crdb_internal r=ajwerner a=fqazi Previous, when we added the crdb_internal.interleaved table that showed all interleaved indexes, however it was impossible tell which table the primary key of the parent table was interleaved. This was inadequate because users could not tell what the parent table was. To address this, this patch removes crdb_internal.interleaved and converts it into two virtual tables interlaved_indexes/interleaved_tables where the one is for non-primary key indexes and the second is for tables interleaved on the primary key. Release note (sql change): Renamed crdb_internal.interleaved to crdb_internal.interlaved_indexes and added crdb_internal.interlaved_table for viewing interleaved tables on the primary key. 62167: sql: incorrect behaviour setting NOT NULL on column and dropping it r=ajwerner a=fqazi Fixes: #47719 Previously, if a column was mutated and then dropped in a single transaction we would still try to validate the dropped column. Additionally, in general if a drop operation occurred in a different transaction we ran the danger of doing something similar. From a behaviour perspective this was bad, since it can lead to unexpected behaviour for users. To address, this patch introduces logic to scan later mutations to check if a drop column occurs. If one does occur then it will skip any operations made irrelevant by the drop. Additionally, for a correctness perspective it will wait for the drop to complete before returning back. Release note (bug fix): A constraint like not null or check on a column made irrelevant by a drop in a later concurrent transaction would lead to incorrect errors / behaviour. Co-authored-by: Faizan Qazi <[email protected]>
Fixes: cockroachdb#47719 Previously, if a column was mutated and then dropped in a single transaction we would still try to validate the dropped column. Additionally, in general if a drop operation occurred in a different transaction we ran the danger of doing something similar. From a behaviour perspective this was bad, since it can lead to unexpected behaviour for users. To address, this patch introduces logic to scan later mutations to check if a drop column occurs. If one does occur then it will skip any operations made irrelevant by the drop. Additionally, for a correctness perspective it will wait for the drop to complete before returning back. Release note (bug fix): A constraint like not null or check on a column made irrelevant by a drop in a later concurrent transaction would lead to incorrect errors / behaviour.
This was uncovered from looking at logs for
TestRandomSyntaxSchemaChangeColumn
. If a column is dropped while a schema change forSET NOT NULL
is in progress on the same column, the validation for the non-null column (which is a SQL query) can fail with the errorcolumn %q does not exist
. The column drop can be queued afterSET NOT NULL
with a different mutation ID, or it can even happen if the two schema changes happen in the same transaction:This particular bug is not very severe; failing with an error is what we should be doing in this case, even though it's not a very good error. The larger question is what we can do to avoid bugs related to interactions between in-progress schema changes and schema changes that are later in line. We're currently dealing with these interactions on an ad-hoc basis, which is going to inevitably lead to similar bugs.
The text was updated successfully, but these errors were encountered: