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

sql: fix nil pointer error in RunPostDeserializationChanges #76198

Merged
merged 1 commit into from
Feb 8, 2022

Conversation

RichardJCai
Copy link
Contributor

@RichardJCai RichardJCai commented Feb 7, 2022

In some restore paths, the privilegeDescriptor would be nil in
RunPostDeserializationChanges, avoid doing work on a nil pointer.

Release note: None

Fixes #76063
Fixes #76062
Fixes #76042

In some restore paths, the privilegeDescriptor would be nil in
RunPostDeserializationChanges, avoid doing work on a nil pointer.

Release note: None
@RichardJCai RichardJCai requested review from adityamaru and a team February 7, 2022 21:06
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@adityamaru adityamaru left a comment

Choose a reason for hiding this comment

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

Thanks!

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: I suppose

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


pkg/sql/catalog/dbdesc/database_desc_builder.go, line 100 at r1 (raw file):

) (hasChanged bool) {
	// If privileges are nil, there is nothing to convert.
	// This case can happen during restore where privileges are not yet created.

I wish I understood this. Why does this happen? Can we fix it in the restore side?

@RichardJCai
Copy link
Contributor Author

RichardJCai commented Feb 7, 2022

:lgtm: I suppose

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

pkg/sql/catalog/dbdesc/database_desc_builder.go, line 100 at r1 (raw file):

) (hasChanged bool) {
	// If privileges are nil, there is nothing to convert.
	// This case can happen during restore where privileges are not yet created.

I wish I understood this. Why does this happen? Can we fix it in the restore side?

I'll dig into this more, wanted to unblock some restore tests locally on master.

#76042 (comment)

Here's an example of the stacktrace thats erroring.

		var b catalog.DescriptorBuilder
		if tableDesc, isTable := desc.(catalog.TableDescriptor); isTable {
			b = tabledesc.NewBuilderForFKUpgrade(tableDesc.TableDesc(), skipFKsWithNoMatchingTable)
		} else {
			b = desc.NewBuilder()
		}
		b.RunPostDeserializationChanges()

seems like for whatever reason, RunPostDeserializationChanges is being called here with a descriptor that has nil privileges.

@RichardJCai
Copy link
Contributor Author

Thanks!

bors r+

@craig
Copy link
Contributor

craig bot commented Feb 8, 2022

Build succeeded:

@craig craig bot merged commit 9b46a59 into cockroachdb:master Feb 8, 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
4 participants