Skip to content

sql/catalog/descs,multiregionccl: allow system database to be made MR#91970

Merged
craig[bot] merged 3 commits intocockroachdb:masterfrom
ajwerner:ajwerner/hydrate-enums-properly-in-system-database
Nov 18, 2022
Merged

sql/catalog/descs,multiregionccl: allow system database to be made MR#91970
craig[bot] merged 3 commits intocockroachdb:masterfrom
ajwerner:ajwerner/hydrate-enums-properly-in-system-database

Conversation

@ajwerner
Copy link
Copy Markdown
Contributor

@ajwerner ajwerner commented Nov 16, 2022

This change is needed in order to convert system database tables to
regional by row.

This PR removes some logic which prevented the system database from being
properly modified. It also adds a test which ensures that the changes happen
as expected.

Epic: CRDB-18596

Release note: None

@ajwerner ajwerner requested a review from a team as a code owner November 16, 2022 02:58
@ajwerner ajwerner requested a review from a team November 16, 2022 02:58
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@ajwerner
Copy link
Copy Markdown
Contributor Author

@jeffswenson you're going to need this

@ajwerner ajwerner changed the title descs: special case the system public schema when hydrating mutable t… sql/catalog/descs,multiregionccl: allow system database to be made MR Nov 16, 2022
@ajwerner ajwerner force-pushed the ajwerner/hydrate-enums-properly-in-system-database branch from 50da5be to 76b2475 Compare November 16, 2022 04:09
@jeffswenson
Copy link
Copy Markdown
Collaborator

Thanks! I'm going to cherry pick this into my sql_instances change so that I can send it out for review.

Copy link
Copy Markdown

@postamar postamar left a comment

Choose a reason for hiding this comment

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

LGTM. I think you took care of all of the gotchas that made the system database special. At least, I can't think of any more.

}
mutableLookupFunc := func(ctx context.Context, id descpb.ID) (catalog.Descriptor, error) {
// This special case exists to deal with the desire to use enums in the
// system, and the fact that the hydration contract is such that when we
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: did you mean "in the system database"?

Required: true,
AvoidLeased: true,
})
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I worry that, whenever we do endow system.public with an actual descriptor, removing this code will be overlooked. I'm not sure what to do about this, though. Perhaps me referencing #89849 is enough.


// This should only every happen to the system database. Unlike many other
// post-deserialization changes, this does not need to last forever to
// support restores. It can be removed in 23.2.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It can be removed in 23.2.

Why is that the case?


// This is a rather contrived test to demonstrate that one can successfully,
// albeit with some arm-twisting, convince the sql layer to make regional-
// by-row tables in the system database.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shouldn't this PR include a new CCL logic test config in which the system database is multi-region? Seems like it'd be worth doing because it'd be nice to add more test cases, then again I have no idea what kind of effort it involves. You be the judge.

…ypes

This change is needed in order to convert system database tables to
regional by row.

Release note: None
This PR removes some logic which prevented the system database from being
properly modified. It also adds a test which ensures that the changes happen
as expected.

Release note: None
There are very old versions out there which do not have versions in their
descriptors. Long ago when these versions were introduced, we incremented
the version on change. The only descriptor we never actually wrote to was
the system descriptor. Those days are over. To account for that, we set
its version to 1 implicitly during post-deserialization. This fixes the
version upgrade tests.

Release note: None
@ajwerner ajwerner force-pushed the ajwerner/hydrate-enums-properly-in-system-database branch from 76b2475 to c61238b Compare November 17, 2022 22:20
Copy link
Copy Markdown
Contributor Author

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

TFTR!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @postamar)


pkg/sql/catalog/dbdesc/database_desc_builder.go line 112 at r3 (raw file):

Previously, postamar (Marius Posta) wrote…

It can be removed in 23.2.

Why is that the case?

When I typed this, my thinking was that we'd have a migration in 23.1 which upgrades the system database. Nothing right now ensures that. I've reworded this comment.


pkg/sql/catalog/descs/hydrate.go line 125 at r3 (raw file):

Previously, postamar (Marius Posta) wrote…

nit: did you mean "in the system database"?

Yes, done.


pkg/sql/catalog/descs/hydrate.go line 136 at r3 (raw file):

Previously, postamar (Marius Posta) wrote…

I worry that, whenever we do endow system.public with an actual descriptor, removing this code will be overlooked. I'm not sure what to do about this, though. Perhaps me referencing #89849 is enough.

Probably it is good enough. The good news is it's still legit in that because the only thing we would need to see out of a mutable descriptor for this descriptor might be a changed name, and I don't think we'll permit changing the name of the public schema (we already don't).


pkg/ccl/multiregionccl/regional_by_row_system_database_test.go line 24 at r3 (raw file):

Previously, postamar (Marius Posta) wrote…

Shouldn't this PR include a new CCL logic test config in which the system database is multi-region? Seems like it'd be worth doing because it'd be nice to add more test cases, then again I have no idea what kind of effort it involves. You be the judge.

I think such a thing will be good. I'll add it in a later PR. Filed #92090.

@ajwerner
Copy link
Copy Markdown
Contributor Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Nov 18, 2022

Build succeeded:

@craig craig bot merged commit f1f666d into cockroachdb:master Nov 18, 2022
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.

4 participants