-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
feat(kv): label names to be unique #15647
Conversation
a3ae35f
to
e9c8929
Compare
e9c8929
to
018b841
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work, have some questions regarding all the string manipulation
@@ -85,7 +92,7 @@ func (s *Service) findLabelByID(ctx context.Context, tx Tx, id influxdb.ID) (*in | |||
|
|||
func filterLabelsFn(filter influxdb.LabelFilter) func(l *influxdb.Label) bool { | |||
return func(label *influxdb.Label) bool { | |||
return (filter.Name == "" || (filter.Name == label.Name)) && | |||
return (filter.Name == "" || (strings.EqualFold(filter.Name, label.Name))) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this change to maintain this with utf8
chars? what's the motivation behind this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah. our CI linter also seemed to agree with the change.
I had changed things originally to deal w/ finding labels case insensitively like so
strings.ToLower(filter.Name) == strings.ToLower(label.Name)
and CI called foul on that use.
|
||
l.Name = strings.TrimSpace(l.Name) | ||
|
||
if err := s.uniqueLabelName(ctx, tx, l); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one thing we may want to do here is move the read for unqiueness outside the update. In cloud this would force a TX imagine, which seems like a bad idea for this. Moving this to a separate read before the update seems like a better idea 🤔. Also, why are we trimming white space on line 265? is that a behavior that we share across the kv implementations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: transactions - I'm just leaving a note here since we chatted about this. This is an even larger issue that may not get addressed in this PR. TX is pretty heavily depended on unfortunately for reading/writing to kv buckets.
|
||
k := make([]byte, influxdb.IDLength+len(l.Name)) | ||
copy(k, orgID) | ||
copy(k[influxdb.IDLength:], []byte(strings.ToLower((l.Name)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we making names unique case insensitive now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. label names should be unique & case agnostic. the UI currently handles all this stuff. feels like it's eagerly loading the labels and doing the label name validation in the browser...
for this change I added, the casing of the label names in the label bucket shouldn't matter & can be a mix of upper and lower case no problem. this system bucket is going to store the down-cased version of the label name, and we'll be using that to decide if a matching label name string already exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excellent! still feels like a service concern, not necessarily a store concern 🤷♂, not even sure where that fits in here tbh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed
6c7dccb
to
8bd8e08
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets roll
Closes #15591
Describe your proposed changes here.