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 bug in zone constraint validation for attributes. #39822

Merged
merged 1 commit into from
Aug 29, 2019

Conversation

rohany
Copy link
Contributor

@rohany rohany commented Aug 22, 2019

Fixes #39800.

Release note: None

@rohany rohany requested review from andreimatei, solongordon and a team August 22, 2019 16:51
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
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.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @andreimatei, @rohany, and @solongordon)


pkg/sql/set_zone_config.go, line 535 at r1 (raw file):

			// Don't perform any validation for pairs with an empty key.
			// These attributes are not real key value pairs, and instead
			// are node attributes, such as +ssd.

Would it still make sense to check for conflicting attributes, like +ssd,-ssd?

Copy link
Contributor Author

@rohany rohany left a comment

Choose a reason for hiding this comment

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

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


pkg/sql/set_zone_config.go, line 535 at r1 (raw file):

Previously, solongordon (Solon) wrote…

Would it still make sense to check for conflicting attributes, like +ssd,-ssd?

you're right. PTAL

Copy link
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.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @andreimatei, @rohany, and @solongordon)


pkg/sql/set_zone_config.go, line 537 at r2 (raw file):

				// are attributes, due to the keys being the same for attributes.
				if curr.Key == "" && other.Key == "" {
					if curr.Value == other.Value {

Nit: You can combine these into a single if. Also maybe we should also check that curr.Type != other.Type? ["+ssd", "+ssd"] is redundant but not really incompatible.

Copy link
Contributor Author

@rohany rohany left a comment

Choose a reason for hiding this comment

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

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


pkg/sql/set_zone_config.go, line 537 at r2 (raw file):

Previously, solongordon (Solon) wrote…

Nit: You can combine these into a single if. Also maybe we should also check that curr.Type != other.Type? ["+ssd", "+ssd"] is redundant but not really incompatible.

I had that originally, but we don't want that -- if the values are not equal (and the keys are both empty), then we fall into the other case and perform an incorrect validation sequence on the attributes. I can update the comment if that isn't clear.

I think we want to keep that +ssd and +ssd is invalid -- to me it looks like its a user error, and they should be notified (for example forgot to copy the correct node attributes in or something).

Copy link
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.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @andreimatei, @rohany, and @solongordon)


pkg/sql/set_zone_config.go, line 537 at r2 (raw file):

Previously, rohany (Rohan Yadav) wrote…

I had that originally, but we don't want that -- if the values are not equal (and the keys are both empty), then we fall into the other case and perform an incorrect validation sequence on the attributes. I can update the comment if that isn't clear.

I think we want to keep that +ssd and +ssd is invalid -- to me it looks like its a user error, and they should be notified (for example forgot to copy the correct node attributes in or something).

Ah right, ok works for me.

@rohany
Copy link
Contributor Author

rohany commented Aug 29, 2019

bors r=solongordon

craig bot pushed a commit that referenced this pull request Aug 29, 2019
39822: sql: Fix bug in zone constraint validation for attributes. r=solongordon a=rohany

Fixes #39800.

Release note: None

Co-authored-by: Rohan Yadav <rohany@alumni.cmu.edu>
@craig
Copy link
Contributor

craig bot commented Aug 29, 2019

Build succeeded

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: validation of constraints referencing attributes is broken
3 participants