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

Consider enforcing no leading underscore in tag keys #11961

Open
e-dard opened this issue Feb 18, 2019 · 9 comments
Open

Consider enforcing no leading underscore in tag keys #11961

e-dard opened this issue Feb 18, 2019 · 9 comments

Comments

@e-dard
Copy link
Contributor

e-dard commented Feb 18, 2019

I would like to consider ensuring that the storage engine does not accept any tag keys with leading underscores, essentially leaving the _ prefix as a private key space for internal series key information.

With that as an invariant, we could make certain performance improvements around reading and parsing keys.

@e-dard
Copy link
Contributor Author

e-dard commented Mar 12, 2019

This was resolved via #12391

@e-dard e-dard closed this as completed Mar 12, 2019
@zhulongcheng
Copy link
Contributor

measurement overwrite _measurement tag in flux table.

// write
any,_field=ff,_measurement=mm,_tag=tt foo="bar"

// query: "from(bucket:"purple")|> range(start:-10h)"
,result,table,_start,_stop,_time,_value,_field,_measurement,_tag
,_result,1,2019-05-31T08:09:08.867394Z,2019-05-31T08:19:08.867394Z,2019-05-31T08:19:00Z,bar,foo,any,tt


at least, _start,_stop,_time,_value,_field,_measurement these tag keys should not be accepted.

@zhulongcheng
Copy link
Contributor

// Normalise the special tag keys to the emitted format.
mv := c.row.Tags.Get(models.MeasurementTagKeyBytes)
c.row.Tags.Delete(models.MeasurementTagKeyBytes)
c.row.Tags.Set(measurementKeyBytes, mv)
c.row.Tags.Delete(models.FieldKeyTagKeyBytes)
c.row.Tags.Set(fieldKeyBytes, fv)
return &c.row
}

@e-dard
Copy link
Contributor Author

e-dard commented Jun 25, 2019

@zhulongcheng thanks for the issue! Hmm I think this is an issue in the read side. @stuartcarnie can you take a look?

@stuartcarnie
Copy link
Contributor

stuartcarnie commented Jun 28, 2019

@e-dard the issue I see here is that _measurement was allowed via a write, and therefore stored as a real tag. Specifically, the series key is stored as:

<org><bucket>,\x00=any,_field=ff,_measurement=mm,_tag=tt,\xff=foo

which should never be allowed.

When a read occurs, the \x00 and \xff bytes are remapped to _measurement and _field respectively, overwriting those stored tags:

// Normalise the special tag keys to the emitted format.
mv := c.row.Tags.Get(models.MeasurementTagKeyBytes)
c.row.Tags.Delete(models.MeasurementTagKeyBytes)
c.row.Tags.Set(measurementKeyBytes, mv)
c.row.Tags.Delete(models.FieldKeyTagKeyBytes)
c.row.Tags.Set(fieldKeyBytes, fv)
return &c.row
}

@e-dard
Copy link
Contributor Author

e-dard commented Jun 28, 2019

@stuartcarnie yeah seems about right. I think then we’ll have to check and block these. I’ll put this on the back log.

@e-dard e-dard reopened this Jun 28, 2019
@stale
Copy link

stale bot commented Sep 26, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 26, 2019
@zhulongcheng
Copy link
Contributor

don't close.

@stale stale bot removed the wontfix label Sep 27, 2019
@8none1
Copy link
Contributor

8none1 commented Dec 13, 2019

Could this be done at the API layer? Would internal calls use the same APIs and so be rejected?

@russorat russorat removed this from the Beta 2.0 milestone Mar 20, 2020
@8none1 8none1 added this to the OSS GA milestone Mar 20, 2020
@russorat russorat removed this from the OSS GA milestone May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants