Skip to content

sql: remove sequence ownership dependency when dropping sequences#50665

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
arulajmani:seq-owned-by
Jun 25, 2020
Merged

sql: remove sequence ownership dependency when dropping sequences#50665
craig[bot] merged 1 commit intocockroachdb:masterfrom
arulajmani:seq-owned-by

Conversation

@arulajmani
Copy link
Copy Markdown
Collaborator

Previously, when a sequence that was owned by a column was being
dropped, we would not remove the sequence ID from the column descriptor
of the column that owned it. As a result, there was a bug where if the
sequence was dropped manually before the table, it would be impossible
to drop the table.

This patch addresses this problem by removing the ownership dependency
on sequence drops.

Fixes #50649

Release note (bug fix): there was a bug previously where if a user
created a sequence owned by a table's column and dropped the sequence,
it would become impossible to drop the table after. This is now fixed.
See attached issue for repro steps.

@arulajmani arulajmani requested a review from solongordon June 25, 2020 20:34
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

@solongordon solongordon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: Glad this was a straightforward fix. Could you spend a little time brainstorming about similar cases we may have missed?

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @arulajmani and @solongordon)


pkg/sql/logictest/testdata/logic_test/sequences, line 1088 at r1 (raw file):


statement ok
CREATE TABLE  t_50649(a INT PRIMARY KEY)

Nit: extra space

Previously, when a sequence that was owned by a column was being
dropped, we would not remove the sequence ID from the column descriptor
of the column that owned it. As a result, there was a bug where if the
sequence was dropped manually before the table, it would be impossible
to drop the table.

This patch addresses this problem by removing the ownership dependency
on sequence drops.

Fixes cockroachdb#50649

Release note (bug fix): there was a bug previously where if a user
created a sequence owned by a table's column and dropped the sequence,
it would become impossible to drop the table after. This is now fixed.
See attached issue for repro steps.
@arulajmani
Copy link
Copy Markdown
Collaborator Author

TFTR. I'll spend some time going over our current testing and see if there are possible cases we might have missed as a followup.

bors r=solongordon

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 25, 2020

Build succeeded

@craig craig bot merged commit f36e1c9 into cockroachdb:master Jun 25, 2020
@thoszhang
Copy link
Copy Markdown

Thanks @arulajmani. Is this getting backported?

@arulajmani
Copy link
Copy Markdown
Collaborator Author

I'm not sure about the backport. cc @solongordon @jordanlewis

@jordanlewis
Copy link
Copy Markdown
Member

Yes, this needs to be backported. Otherwise, on 20.1 and on 19.2, you can still corrupt your tables by dropping sequences that have ownership relationships to those tables.

@jordanlewis
Copy link
Copy Markdown
Member

Err, this doesn't exist on 19.2, does it. So just 20.1 is what I meant to say.

@arulajmani
Copy link
Copy Markdown
Collaborator Author

Doesn't exist on 19.2; I'll backport to 20.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql: dropping a sequence with a sequence owners corrupts the table that owns the sequence

5 participants