-
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: create new slice when removing backreference items #97631
sql: create new slice when removing backreference items #97631
Conversation
21cf090
to
fe645a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @chengxiong-ruan)
pkg/sql/alter_table.go
line 1615 at r1 (raw file):
return nil, err } if depDesc.Dropped() {
Is there another bug we are fixing here, we should maybe have a commit message and release not if it was public.
pkg/sql/drop_table.go
line 650 at r1 (raw file):
refs []descpb.TableDescriptor_Reference, id descpb.ID, ) []descpb.TableDescriptor_Reference { var updatedRefs []descpb.TableDescriptor_Reference
Pre-allocate based on the size of the old refs, incase nothing gets removed. That way we don't keep on growing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @chengxiong-ruan and @fqazi)
pkg/sql/drop_table.go
line 650 at r1 (raw file):
Previously, fqazi (Faizan Qazi) wrote…
Pre-allocate based on the size of the old refs, incase nothing gets removed. That way we don't keep on growing.
This can be N^2 now in the worst case, right? Some other options are to collect the ids to remove or to clone the slice before iterating. This is yet another reason why the legacy schema changer is bad. I imagine the recursion makes this all tricky. What is the loop we were messing up?
Previously, ajwerner wrote…
Yeah, N^2 can be bad if the dep graph is large. |
fe645a5
to
b6680ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @fqazi)
pkg/sql/alter_table.go
line 1615 at r1 (raw file):
Previously, fqazi (Faizan Qazi) wrote…
Is there another bug we are fixing here, we should maybe have a commit message and release not if it was public.
Yeah, another bug was accidentally fixed here...I added both bugs to commit message and added release note.
pkg/sql/drop_table.go
line 650 at r1 (raw file):
Previously, chengxiong-ruan (Chengxiong Ruan) wrote…
Yeah, N^2 can be bad if the dep graph is large.
The loops under concern here is DROP INDEX CASCADE and DROP COLUMN CASCADE
But yeah, I think collecting ids to drop is a good idea here.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this much more
b6680ab
to
b2d689e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 3 files at r2, 4 of 4 files at r3, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @chengxiong-ruan)
b2d689e
to
bf5d0f3
Compare
bf5d0f3
to
181008f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version gate feels like it should have been a separate PR.
Reviewed 1 of 3 files at r2, 1 of 4 files at r3.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @chengxiong-ruan and @fqazi)
pkg/sql/schemachanger/scdecomp/decomp.go
line 123 at r4 (raw file):
panic( scerrors.NotImplementedErrorf( nil,
nit: can you name the nil
with a comment?
TFTRs! |
bors r- |
Canceled. |
|
Sorry.. terrible formatting.... |
Fixes: cockroachdb#97546 Fixes: cockroachdb#96368 We are reusing the underlying slots of the `DependedOnBy` slice when removing items from it. This is problematic because we normally have to iterate the same slice to figure out what to drop. Iterating on a slice which is rewritten can be problematic unless we always know how to smartly move the cursor backward. This commit remove such kind of hazard by collecting descriptor IDs to drop before actually dropping everything. Releaste note (sql change): This commit fixes two bugs prevent users from doing `DROP COLUMN CASCADE` and `DROP INDEX CASCADE` when dependecies on the Table from Views and Functions get complex. They all happened When a table is referenced multiple times in more than one Views and Functions. Release note: None.
181008f
to
2e05878
Compare
Previously, ajwerner wrote…
done. |
TFTRs! |
Build succeeded: |
Encountered an error creating backports. Some common things that can go wrong:
You might need to create your backport manually using the backport tool. error creating merge commit from 2e05878 to blathers/backport-release-22.2-97631: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict [] you may need to manually resolve merge conflicts with the backport tool. Backport to branch 22.2.x failed. See errors above. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
In cockroachdb#97631 we refactor the method to drorp index and column cascade dependents. But we didn't return a correct droppedViews, instead, we returned a nil. This wasn't caught by the `event_log` logic test because we skip `local-legacy-schema-changer` test config in v23.1. Luckily,this was caught when backporting to v22.2 because there was a fallback. Epic: None Release note: None
In cockroachdb#97631 we refactor the method to drorp index and column cascade dependents. But we didn't return a correct droppedViews, instead, we returned a nil. This wasn't caught by the `event_log` logic test because we skip `local-legacy-schema-changer` test config in v23.1. Luckily,this was caught when backporting to v22.2 because there was a fallback. Epic: None Release note: None
In cockroachdb#97631 we refactor the method to drorp index and column cascade dependents. But we didn't return a correct droppedViews, instead, we returned a nil. This wasn't caught by the `event_log` logic test because we skip `local-legacy-schema-changer` test config in v23.1. Luckily,this was caught when backporting to v22.2 because there was a fallback. Epic: None Release note: None
96382: jobs: add VIEWJOB role option r=HonoreDB a=jayshrivastava #### jobs: allow CONTROLJOB users to view all jobs This is a preliminary change before adding the `VIEWJOB` role option. The purpose of the `VIEWJOB` role option will be to allow TSEs to view jobs in admin clusters without modifying them. This requires access to view all jobs, including ones owned by admins. Adding `VIEWJOB` will conflict with the present `CONTROLJOB` implementation. It will be stronger than `CONTROLJOB` because it lets one view admin jobs when `CONTROLJOB` doesn't, yet it will be weaker because it only allows viewing jobs and not pause/cancel/resume-ing them. This change is introduced to make `CONTROLJOB` at least as strong as `VIEWJOB`: it now allows for all jobs to be viewed. In other words, `VIEWJOB` lets you do a subset of things `CONTROLJOB` lets you do. Also, the reason that `CONTROLJOB` prevents access to admin-owned jobs is not well defined. This is tracked in #96432. Release note (general change): Previously, users with the `CONTROLJOB` role option could not view owned by admins (ex. via `SHOW JOBS`). Now, they can. Epic: none --- #### jobs: add VIEWJOB role option Release note (general change): Users can now be granted the `VIEWJOB` role option to be able to view all jobs (ex. via `SHOW JOBS`). This role can be revoked using `NOVIEWJOB`. Epic: none 97746: sql,schemachanger: ADD PRIMARY KEY NOT VALID returns an error r=Xiang-Gu a=Xiang-Gu Fixes #96729 Release note (sql change): When we add an unvalidated PK constraint to a table, assuming its PK was on the implicit "rowid" column, will return an error. This is compatible to what PG will do. 97802: sql: return droppedView instead of nil r=chengxiong-ruan a=chengxiong-ruan In #97631 we refactor the method to drorp index and column cascade dependents. But we didn't return a correct droppedViews for event logging, instead, we returned a nil. This wasn't caught by the `event_log` logic test because we `local-legacy-schema-changer` test config. Though this was caught when backporting to v22.2 because there was a fallback. Epic: None Release note: None Co-authored-by: Jayant Shrivastava <[email protected]> Co-authored-by: Xiang Gu <[email protected]> Co-authored-by: Chengxiong Ruan <[email protected]>
Fixes: #97546
Fixes: #96368
Previously we reused the underlying slots of the
DependedOnBy
slice when removing items from it. This is problematic because we normally have to iterate the same slice to figure out what to drop. Iterating on a slice which is rewritten can be problematic unless we always know how to smartly move the cursor backward. This commit changes it to just create a new slice to avoid the hazzard.Release note: None.