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

Show Tag Keys Problem with Given Retention Policy #6480

Closed
lvheyang opened this issue Apr 27, 2016 · 2 comments
Closed

Show Tag Keys Problem with Given Retention Policy #6480

lvheyang opened this issue Apr 27, 2016 · 2 comments
Milestone

Comments

@lvheyang
Copy link
Contributor

Bug report

System info: [InfluxDB 0.12.2, Mac OS X 10.11.4]

Steps to reproduce:

# create database 
curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"

# create retention policy * 2 (myrp1, myrp2),  set myrp2 as DEFAULT retention policy
curl -G http://localhost:8086/query --data-urlencode "q=CREATE RETENTION POLICY myrp1 ON mydb DURATION 365d REPLICATION 1 DEFAULT"
curl -G http://localhost:8086/query --data-urlencode "q=CREATE RETENTION POLICY myrp2 ON mydb DURATION 365d REPLICATION 1 DEFAULT"

# insert points into myrp1.cpu
curl -i -XPOST 'http://localhost:8086/write?db=mydb&rp=myrp1' --data-binary 'cpu,host=server01,region=us-west value=0.64'

Expected behavior and Actual behavior

# show tag keys of measurement cpu
curl -G http://localhost:8086/query\?db\=mydb --data-urlencode "q=show tag keys from cpu"

expected: {"results":[{}]}
got: {"results":[{}]}

# show tag keys of measurement cpu in myrp2 
curl -G http://localhost:8086/query\?db\=mydb --data-urlencode "q=show tag keys from mydb.myrp2.cpu"

expected: {"results":[{}]}
got: {"results":[{}]}

# show tag keys of measurement cpu in myrp1
curl -G http://localhost:8086/query\?db\=mydb --data-urlencode "q=show tag keys from mydb.myrp1.cpu"

expected: {"results":[{"series":[{"name":"cpu","columns":["tagKey"],"values":[["host"],["region"]]}]}]}
got: {"results":[{}]}

Additional info:

  • Query Log: All of the statements were rewrite to SELECT tagKey FROM mydb.myrp2._tagKeys WHERE _name = 'cpu'. It rewrite every source into default retention policy.
[query] 2016/04/27 20:18:22 SELECT tagKey FROM mydb.myrp2._tagKeys WHERE _name = 'cpu'
[httpd]2016/04/27 20:18:22 ::1 - - [27/Apr/2016:20:18:22 +0800] GET /query?db=mydb&q=show+tag+keys+from+mydb.myrp1.cpu HTTP/1.1 200 16 - curl/7.43.0 223a4a69-0c72-11e6-8008-000000000000 542.083µs
[query] 2016/04/27 20:18:28 SELECT tagKey FROM mydb.myrp2._tagKeys WHERE _name = 'cpu'
[httpd]2016/04/27 20:18:28 ::1 - - [27/Apr/2016:20:18:28 +0800] GET /query?db=mydb&q=show+tag+keys+from+mydb.myrp2.cpu HTTP/1.1 200 16 - curl/7.43.0 25ddf2af-0c72-11e6-8009-000000000000 378.017µs
[query] 2016/04/27 20:18:33 SELECT tagKey FROM mydb.myrp2._tagKeys WHERE _name = 'cpu'
[httpd]2016/04/27 20:18:33 ::1 - - [27/Apr/2016:20:18:33 +0800] GET /query?db=mydb&q=show+tag+keys+from+cpu HTTP/1.1 200 16 - curl/7.43.0 28d8e93c-0c72-11e6-800a-000000000000 630.81µs
  • The possible problem position in source code (in influxql/statement_rewriter.go line 157). I noticed that the previous statement's database & retention policy was discarded. But I don't know why? Are there any other considerations?
func rewriteShowTagKeysStatement(stmt *ShowTagKeysStatement) (Statement, error) {
    // Check for time in WHERE clause (not supported).
    if HasTimeExpr(stmt.Condition) {
        return nil, errors.New("SHOW TAG KEYS doesn't support time in WHERE clause")
    }

    return &SelectStatement{
        Fields: []*Field{
            {Expr: &VarRef{Val: "tagKey"}},
        },
        Sources: []Source{
            &Measurement{Name: "_tagKeys"},  // why not use previous statement's db and rp
        },
        Condition:  rewriteSourcesCondition(stmt.Sources, stmt.Condition),
        Offset:     stmt.Offset,
        Limit:      stmt.Limit,
        SortFields: stmt.SortFields,
        OmitTime:   true,
        Dedupe:     true,
    }, nil
}

thx

@lvheyang lvheyang changed the title Cannot Show Tag Keys Cannot Show Tag Keys Except Default Retention Policy Apr 27, 2016
@lvheyang lvheyang changed the title Cannot Show Tag Keys Except Default Retention Policy Show Tag Keys Problem with Given Retention Policy Apr 27, 2016
@lvheyang
Copy link
Contributor Author

I try to fix it. related pr #6481

@lvheyang
Copy link
Contributor Author

merged & closed
thx

@timhallinflux timhallinflux added this to the 0.13.0 milestone Dec 20, 2016
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

3 participants