Skip to content
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

descs: push descriptor type hydration into the desc.Collection #51621

Merged
merged 1 commit into from
Jul 23, 2020

Conversation

rohany
Copy link
Contributor

@rohany rohany commented Jul 20, 2020

Fixes #49484.
Preparation for #51385.

Up until now, the planner was responsible for installing user defined
type metadata in tables that contained user defined types. This was
slightly messy and caused leakage of responsibility regarding when
descriptors had user defined types vs when they didn't. This commit
pushes that responsibility into the descs.Collection. It also paves
the way for work to avoid copying ImmutableTableDescriptors that
contain user defined types every time that they need hydration.

Release note: None

@rohany rohany requested review from ajwerner and thoszhang July 20, 2020 21:37
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@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.

Reviewed 3 of 4 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @lucy-zhang, and @rohany)


pkg/sql/catalog/descs/collection.go, line 263 at r1 (raw file):

		// not shared.
		return desc, sqlbase.HydrateTypesInTableDescriptor(ctx, t.TableDesc(), sqlbase.TypeLookupFunc(getType))
	case *sqlbase.ImmutableTableDescriptor:

How does one get a handle to an ImmutableTableDescriptor that isn't hydrated?

@rohany
Copy link
Contributor Author

rohany commented Jul 21, 2020

How does one get a handle to an ImmutableTableDescriptor that isn't hydrated?

The lease manager/uncached accessor is pulling up table descs and creating immutable descs to hand out to higher levels of name resolution (i.e. the collection) -- those aren't coming hydrated.

Copy link
Contributor

@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.

The lease manager/uncached accessor is pulling up table descs and creating immutable descs to hand out to higher levels of name resolution (i.e. the collection) -- those aren't coming hydrated.

That's sort of exactly my question. Is the Collection the only thing that ever has handles to unhydrated ImmutableTableDescriptors?

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @lucy-zhang and @rohany)

@rohany
Copy link
Contributor Author

rohany commented Jul 21, 2020

Yeah, I think that is a reasonable separation -- everything below the collection needs to hydrate descriptors if they want to use them and know that they have user defined types.

@rohany rohany force-pushed the hydrated-type-cache branch from 91a0c1b to 82a59a2 Compare July 22, 2020 03:07
@rohany
Copy link
Contributor Author

rohany commented Jul 22, 2020

Rebased, ready for review.

Copy link
Contributor

@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.

:lgtm_strong:

Reviewed 4 of 4 files at r2.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @lucy-zhang and @rohany)

Fixes cockroachdb#49484.
Preparation for cockroachdb#51385.

Up until now, the planner was responsible for installing user defined
type metadata in tables that contained user defined types. This was
slightly messy and caused leakage of responsibility regarding when
descriptors had user defined types vs when they didn't. This commit
pushes that responsibility into the descs.Collection. It also paves
the way for work to avoid copying ImmutableTableDescriptors that
contain user defined types every time that they need hydration.

Release note: None
@rohany rohany force-pushed the hydrated-type-cache branch from 82a59a2 to eaeb7c1 Compare July 23, 2020 16:31
@rohany
Copy link
Contributor Author

rohany commented Jul 23, 2020

bors r+

@craig
Copy link
Contributor

craig bot commented Jul 23, 2020

Build succeeded:

@craig craig bot merged commit fb77854 into cockroachdb:master Jul 23, 2020
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: pull type resolution code in more specific packages
3 participants