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

[0.9.4.2] Storing strings is not working #4584

Closed
drb-digital opened this issue Oct 27, 2015 · 18 comments
Closed

[0.9.4.2] Storing strings is not working #4584

drb-digital opened this issue Oct 27, 2015 · 18 comments
Assignees

Comments

@drb-digital
Copy link

Hi,

I am trying to store strings in influxdb 0.9.4.2, using influxdb-java. Line protocol output of influxdb-java looks like: test,identifier=Testperson value="test test test" 1445944679577000000

But no matter if I am using influxdb-java or the influxdb web interface (with the same line protocol data), the point is not stored to my database. Web interface doesn't report any error, but I can't query data by
SELECT value FROM test, it says Success! (no results to display) then.

When I change my timestamp to seconds instead of nanoseconds, everything is working fine. Also if I am storing floats instead of strings everything is fine. Am I doing something wrong or is this an error in influxdb?

Greetings
Dennis

@beckettsean
Copy link
Contributor

@DennisBauer can you try using the CLI or direct curl statements to write and query the points? That would allow us to eliminate influxdb-java or the admin UI (and the resulting browser complications) as the causes of the issue.

Also, the more of the actual CLI or curl statements you can include here, the easier it is for us. Usually issues like this turn out to be subtle syntax problems rather than actual bugs with the database. It's nigh impossible to find syntax issues without actual code to read.

For example, running 0.9.4.1 I'm able to insert and query your example just fine:

$ influx
Connected to http://localhost:8086 version 0.9.4.1
InfluxDB shell 0.9.4.1
> use mydb
Using database mydb
> drop measurement test
> insert test,identifier=Testperson value="test test test" 1445944679577000000
> select * from test
name: test
----------
time                identifier  value
2015-10-27T11:17:59.577Z    Testperson  test test test

> 

@beckettsean beckettsean changed the title Storing strings is not working [0.9.4.2] Storing strings is not working Oct 27, 2015
@otoolep otoolep self-assigned this Oct 27, 2015
@benschwarz
Copy link

@beckettsean Hmm, I'm on the same version as you, your example works, but when I try:

INSERT test,apiKey="gfb-123",countryCode="US",city="San Francisco" value=9.7

I get unable to parse

@jwilder
Copy link
Contributor

jwilder commented Oct 27, 2015

@benschwarz The format you are using is not quite right. Tags should not have double-quotes and the space in San Francisco needs to be escaped. Try:

INSERT test,apiKey=gfb-123,countryCode=US,city=San\ Francisco value=9.7

@benschwarz
Copy link

@jwilder Hmm, I think we need to improve the documentation a little here.

NOTE: Measurements, tags, and field names containing any character other than (A-Z,a-z,0-9,_) or starting with a digit must be double-quoted. More information on the line protocol can be found on the Reading and Writing Data page.

This leads me to believe that most things should be double quoted in case of illegal characters — of course, when I go to the "reading and writing data" page, I'm presented with no information about quoting, or escaping.

What do you think? Perhaps worth adding something? (Should we track this in another issue? I totally hijacked here thinking I had the same issue.)

@jwilder
Copy link
Contributor

jwilder commented Oct 27, 2015

@beckettsean
Copy link
Contributor

@benschwarz that quote from the Getting Started page is indeed wrong. I'll get that fixed.
https://github.com/influxdb/influxdb.com/issues/434

The https://influxdb.com/docs/v0.9/write_protocols/write_syntax.html page is the definitive one for line protocol syntax.

@otoolep
Copy link
Contributor

otoolep commented Oct 28, 2015

@beckettsean -- sounds like we can close this?

@drb-digital
Copy link
Author

@beckettsean:
Like you mentioned, I tried again using CLI. But the result is the same. There is no error message, but my query is empty too. See the following log:

Connected to http://localhost:8086 version 0.9.4.2
InfluxDB shell 0.9.4.2
> use labtest
Using database labtest
> insert test,identifier=Testperson value="test test test" 1445944679577000000
> select * from test
ERR: statement must have at least one field in select clause
> select value from test
>

@beckettsean
Copy link
Contributor

@DennisBauer I am at a loss to explain what you are seeing. I just spun up a new 0.9.4.2 server and the exact CLI session you show works fine:

root@sean-0:~# /opt/influxdb/influx
Connected to http://localhost:8086 version 0.9.4.2
InfluxDB shell 0.9.4.2
> create database mydb
> use mydb
Using database mydb
> insert test,identifier=Testperson value="test test test" 1445944679577000000
> select * from test
name: test
----------
time                identifier  value
2015-10-27T11:17:59.577Z    Testperson  test test test

> select value from test
name: test
----------
time                value
2015-10-27T11:17:59.577Z    test test test

There is no error message, but my query is empty too.

An empty return is the expected result if there are no matching records. The more concerning error is the one from the select * statement, as that does have fields in the select clause.

I can only conclude that there's something specific to your installation that is leading to the issues.

Was labtest an otherwise empty database when you tried that test?

What are the results of SHOW MEASUREMENTS, SHOW TAG KEYS, and SHOW FIELD KEYS on labtest?

@drb-digital
Copy link
Author

@beckettsean The weird thing is, that I already dropped labtest and created a new one (same name) with no difference in the result. Now I created a database with a different name (labtestnew) and everything is working fine:

Connected to http://localhost:8086 version 0.9.4.2
InfluxDB shell 0.9.4.2
> create database labtestnew
> use labtestnew
Using database labtestnew
> insert test,identifier=Testperson value="test test test" 1445944679577000000
> select * from test
name: test
----------
time                            identifier      value
2015-10-27T11:17:59.577Z        Testperson      test test test

> select value from test
name: test
----------
time                            value
2015-10-27T11:17:59.577Z        test test test

Isn't data deleted when I drop database and create a new one with the same name? Does that mean everytime I drop a database because of some problems I can't use the same name again?

Whats is also weird is that SHOW MEASUREMENTS and SHOW TAG KEYS is getting results in labtest:

> use labtest
Using database labtest
> select * from test
ERR: statement must have at least one field in select clause
> show measurements
name: measurements
------------------
name
test

> show tag keys
name: test
----------
tagKey
identifier

>

@beckettsean
Copy link
Contributor

Isn't data deleted when I drop database and create a new one with the same name?

It certainly should be. Perhaps the metastore isn't fully purging.

Does the behavior persist through a restart of the daemon?

@beckettsean beckettsean reopened this Oct 30, 2015
@drb-digital
Copy link
Author

Restarting the daemon helped to store data, but there is another problem now. No matter which timestamp I include, 1970-01-17 will be stored. This is independent from the database, it happens on all databases (even the ones which were working quite well)

@beckettsean
Copy link
Contributor

@DennisBauer that sounds like a units mismatch. InfluxDB stores every timestamp as a nanosecond timestamp unless otherwise configured during the write.

If you were supplying microsecond timestamps without microsecond precision, that would make all timestamps appear to be from Jan 17th, 1970:

> insert precision value="seconds" 1446485540
> insert precision value="milliseconds" 1446485540000
> insert precision value="microseconds" 1446485540000000
> select * from precision
name: precision
---------------
time                value
1970-01-01T00:00:01.44648554Z   seconds
1970-01-01T00:24:06.48554Z  milliseconds
1970-01-17T17:48:05.54Z     microseconds

Review the Precision query string parameter from the line protocol syntax guide to see how to write microsecond timestamps.

The errors caused by dropping and recreating the database are covered by #3551 and #4636, which are cleaner issues. Closing this in favor of those.

@drb-digital
Copy link
Author

@beckettsean I know that InfluxDB expects nanoseconds by default. Thats why I used the query which we discussed above:
insert test,identifier=Testperson value="test test test" 1445944679577000000

But still I am getting wrong timestamps. But not only in my test database, but also in older databases which were working fine before.

@beckettsean
Copy link
Contributor

@DennisBauer can you try the insert with curl while explicitly using the precision parameter?

`curl -iX POST 'http://localhost:8086/write?db=labtest&precision=n' --data-binary 'test,identifier=Testperson value="test test test" 1445944679577000000'

@drb-digital
Copy link
Author

@beckettsean After restarting the daemon again, everything works fine. This has been weird to me for quite a time now: sometimes influxdb works quite well, other times there is no (visible) error message and everything seems to work but indeed it's not. Well nevertheless this issue seems to be solved now. Thansk again for your support!

@beckettsean
Copy link
Contributor

@DennisBauer the latest influxdb-java was recently pushed to Maven. If you haven't updated to the most recent release that might help.

@drb-digital
Copy link
Author

@beckettsean Thanks for the hint, I already updated my project a couple of days ago.

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

No branches or pull requests

5 participants