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

Should not be able to panic the database by using particular field keys #3010

Closed
shaileshswapnil opened this issue Jun 17, 2015 · 11 comments
Closed
Assignees
Milestone

Comments

@shaileshswapnil
Copy link

Hi,
I was trying to include field named "time" which is similar to the predefined "time" field.
While doing so, it didn't gave any error. But while querying the "time" from the measurement, it gave error and after that no single query is executing, even "select" or "show measurements" not working.
So, I need to go to the /etc/init.d/ and restart the service.
Can anyone explain this issue?

@otoolep
Copy link
Contributor

otoolep commented Jun 17, 2015

@shaileshswapnil -- we need more detail.

Can you please show us the sequence of problematic commands using curl? See the link before for examples:

https://github.com/influxdb/influxdb/blob/master/CONTRIBUTING.md#bug-reports

@shaileshswapnil
Copy link
Author

Sequence of generating the bug/issue

#create the database
 curl -G http://192.168.1.219:8086/query --data-urlencode "q=CREATE DATABASE test"

#insert data points
curl -X POST -d '{"database":"test","points":[{"measurement":"demo","fields":{"value":1000,"time":"1424519098"}}]}' 'http://192.168.1.219:8086/write'

curl -X POST -d '{"database":"test","points":[{"measurement":"demo","fields":{"value":1000,"node_time":"1424519098"}}]}' 'http://192.168.1.219:8086/write'

#Returns correct result
curl -G http://192.168.1.219:8086/query  --data-urlencode 'db=test' --data-urlencode q='select * from /demo/'

#returns error
curl -G http://192.168.1.219:8086/query  --data-urlencode 'db=test' --data-urlencode q='select time from /demo/'

curl: (52) Empty reply from server

#Connection lost... need to restart the service from /etc/init.d/ 
curl -G http://192.168.1.219:8086/query  --data-urlencode 'db=test' --data-urlencode q='select * from /demo/'

curl: (7) couldn't connect to host

After querying the time, which generally we can not do I guess, the influx service is affected and not allowing me to perform any query without restarting.

OS: Linux centos65 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Influx version: 0.9

Installed it using wget

@otoolep
Copy link
Contributor

otoolep commented Jun 17, 2015

time is a reserved field. While the system shouldn't panic (as I guess it is doing) the query language does not support the supplied syntax.

@otoolep
Copy link
Contributor

otoolep commented Jun 17, 2015

In addition you are using a string when setting time in your writes. It must be an integer.

https://influxdb.com/docs/v0.9/concepts/reading_and_writing_data.html

You may actually wish changing to the line protocol, since the JSON API is deprecated.

@otoolep
Copy link
Contributor

otoolep commented Jun 17, 2015

For the record, the panic that is occurring is as follows:

panic: interface conversion: interface is string, not map[string]interface {}

goroutine 71 [running]:
github.com/influxdb/influxdb/influxql.(*MapReduceJob).processRawResults(0xc208011f10, 0xc208178158, 0x1, 0x1, 0x1)
        /home/philip/repos/influxdb/src/github.com/influxdb/influxdb/influxql/engine.go:745 +0xa64
github.com/influxdb/influxdb/influxql.(*MapReduceJob).processRawQuery(0xc208011f10, 0xc2081746c0, 0x0)
        /home/philip/repos/influxdb/src/github.com/influxdb/influxdb/influxql/engine.go:355 +0xa39
github.com/influxdb/influxdb/influxql.(*MapReduceJob).Execute(0xc208011f10, 0xc2081746c0, 0xc208133f00)
        /home/philip/repos/influxdb/src/github.com/influxdb/influxdb/influxql/engine.go:81 +0x11ec
github.com/influxdb/influxdb/influxql.(*Executor).execute(0xc2080e44c0, 0xc2081746c0)
        /home/philip/repos/influxdb/src/github.com/influxdb/influxdb/influxql/engine.go:926 +0xba
created by github.com/influxdb/influxdb/influxql.(*Executor).Execute
        /home/philip/repos/influxdb/src/github.com/influxdb/influxdb/influxql/engine.go:905 +0x5a

@otoolep otoolep self-assigned this Jun 17, 2015
@otoolep otoolep added this to the 0.9.2 milestone Jun 17, 2015
@otoolep
Copy link
Contributor

otoolep commented Jun 17, 2015

@shaileshswapnil -- if you want to get the times back, you have to SELECT at least 1 other field in your data. You can't just SELECT time.

@shaileshswapnil
Copy link
Author

Okay
Than the panic is the main issue while querying the time field.

And for the time field which you have mentioned that it is a reserved field, I am specifying it inside the "fields":{ }, so it should be treated as user defined value and can have either string or integer or decimal or whatever user will define. Not as reserved time field which is outside of "fields":{ }

Yes JSON API is deprecated but still we can tweak according to the usability, similar to 0.8.

@beckettsean
Copy link
Contributor

@shaileshswapnil time is a reserved word in the query language. It's going to lead to continuing pain to re-use that exact string as a field or tag key. Can you use something like time1 or time_field instead?

I've verified that even double-quoting the field key still causes a database panic, which is not good. We seem to handle time as a measurement name just fine, but as a field key it is fully unsupported.

> insert time,tag=key value=1 101010101011010
> insert time,tag=key value=1,time=10 1100101010101011010
> select * from time
name: time
tags: tag=key
time                value
----                -----
1970-01-02T04:03:30.10101101Z   map[value:1]
2004-11-10T15:36:50.10101101Z   map[time:10 value:1]

> select time from time
ERR: Get http://localhost:8086/query?db=mydb&q=select+time+from+time: EOF
> select "time" from time
ERR: Get http://localhost:8086/query?db=mydb&q=select+%22time%22+from+time: EOF

InfluxDB panicked on both of the last SELECT statements with panic: interface conversion: interface is int64, not map[string]interface {}

@shaileshswapnil
Copy link
Author

Well.. seems the problem has been identified. Waiting to get it fixed soon along with proper error message while using reserved fields or some improper query. It must identify the illogical query and either return relevant result or prompt to user.

Will be happy if I can contribute anything regarding this issue or other.

@beckettsean
Copy link
Contributor

The fix is either to ban the use of certain words as field keys, prevent the database from panicking when someone does so, or both. Not yet decided what the solution will be.

In the meantime the workaround is trivial. Don't use any query language literal as a tag or field key.

@beckettsean beckettsean changed the title Querying time field is effecting the running influxdb service Should not be able to panic the database by using particular field keys Jun 19, 2015
@beckettsean beckettsean modified the milestones: 0.9.4, 0.9.2 Jul 8, 2015
@otoolep
Copy link
Contributor

otoolep commented Aug 20, 2015

curl -G http://127.0.0.1:8086/query --data-urlencode "q=CREATE DATABASE test"
curl -X POST -d '{"database":"test","points":[{"measurement":"demo","fields":{"value":1000,"time":"1424519098"}}]}' 'http://127.0.0.1:8086/write'
curl -X POST -d '{"database":"test","points":[{"measurement":"demo","fields":{"value":1000,"node_time":"1424519098"}}]}' 'http://127.0.0.1:8086/write'
curl -G http://127.0.0.1:8086/query  --data-urlencode 'db=test' --data-urlencode q='select time from /demo/'

Test case with 127.0.0.1.

@otoolep otoolep modified the milestones: 0.9.3, 0.9.4 Aug 20, 2015
otoolep added a commit that referenced this issue Aug 21, 2015
otoolep added a commit that referenced this issue Aug 21, 2015
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