Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

InfluxDB bundle generates incomplete database queries at openHAB startup #1879

Closed
hoalex opened this issue Dec 24, 2014 · 9 comments
Closed
Labels
Milestone

Comments

@hoalex
Copy link

hoalex commented Dec 24, 2014

I'm using the InfluxDB persistence bundle to store the temperature values of my FHT80b devices. I also have defined "restoreOnStartup" in "influxdb.persist", so that the last temperature values are set after restarting openHAB. Sadly, this does not work for me.

When restarting openHAB, I get the following messages at stdout for every item that I have defined in influxdb.persist:

17:39:46.018 [DEBUG] [i.i.InfluxDBPersistenceService:265  ] - got a query
17:39:46.019 [DEBUG] [i.i.InfluxDBPersistenceService:340  ] - got page size 1
17:39:46.019 [DEBUG] [i.i.InfluxDBPersistenceService:349  ] - query string: select value, time from FHT_AI where
17:39:46.038 [ERROR] [i.i.InfluxDBPersistenceService:354  ] - query failed with database error
17:39:46.041 [ERROR] [i.i.InfluxDBPersistenceService:211  ] - database connection error may be wrong password, username or dbname: {}
java.lang.RuntimeException: syntax error, unexpected $end
select value, time from FHT_AI where
                                    ^
    at org.influxdb.impl.InfluxDBErrorHandler.handleError(InfluxDBErrorHandler.java:19) ~[na:na]
    at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:242) ~[na:na]
    at org.influxdb.impl.$Proxy74.query(Unknown Source) ~[na:na]
    at org.influxdb.impl.InfluxDBImpl.query(InfluxDBImpl.java:110) ~[na:na]
    at org.openhab.persistence.influxdb.internal.InfluxDBPersistenceService.query(InfluxDBPersistenceService.java:352) [bundlefile:na]
    at org.openhab.core.persistence.internal.PersistenceManager.initialize(PersistenceManager.java:382) [org.openhab.core.persistence_1.7.0.201412230208.jar:na]
    at org.openhab.core.persistence.internal.PersistenceManager.initializeItems(PersistenceManager.java:212) [org.openhab.core.persistence_1.7.0.201412230208.jar:na]
    at org.openhab.core.persistence.internal.PersistenceManager.initializeItems(PersistenceManager.java:204) [org.openhab.core.persistence_1.7.0.201412230208.jar:na]
    at org.openhab.persistence.influxdb.internal.InfluxDBPersistenceService.updated(InfluxDBPersistenceService.java:258) [bundlefile:na]
    at org.eclipse.equinox.internal.cm.ManagedServiceTracker$1.run(ManagedServiceTracker.java:183) [org.eclipse.equinox.cm_1.0.400.v20120522-1841.jar:na]
    at org.eclipse.equinox.internal.cm.SerializedTaskQueue$1.run(SerializedTaskQueue.java:36) [org.eclipse.equinox.cm_1.0.400.v20120522-1841.jar:na]

Obviously, there is a part missing after the "where" clause.
New temperature values are correctly saved in InfluxDB, and can be queried by the InfluxDB web interface and also Grafana, so the "saving" part works just fine. It's only the initial startup, i.e. the "restoreOnStartup" part, that fails.

I'm using the following versions:
openHAB: 1.7.0 nightly from 24/12/2014
InfluxDB persistence bundle: 1.7.0 nightly form 24/12/2014
InfluxDB: 0.8.7
running on Debian Wheezy 7.7 (64-bit)

java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.3) (7u71-2.5.3-2~deb7u1)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

Any help on this?

@udo1toni
Copy link
Contributor

openHAB should be run with oracle Java (1.7 or 1.8) due to compability problems

@hoalex
Copy link
Author

hoalex commented Dec 26, 2014

Thanks for the advice @udo1toni, I will try installing Oracle Java instead and will report back!

@hoalex
Copy link
Author

hoalex commented Dec 27, 2014

I installed Oracle Java 1.8, but unfortunately, the behaviour I described above still persists. Any other ideas?

@itn3rd77
Copy link
Contributor

I can confirm the behaviour @hoalex has described. What has changed in 1.7?

@theoweiss
Copy link
Member

I will have a look at it.

@theoweiss
Copy link
Member

I found the bug.
The bug is triggered by an inconsistent FilterCriteria as query() argument when restoreOnStartup is used:
23:58:56.439 [DEBUG] [i.i.InfluxDBPersistenceService:266 ] - got a query
23:58:56.439 [TRACE] [i.i.InfluxDBPersistenceService:293 ] - filter state: null
23:58:56.440 [TRACE] [i.i.InfluxDBPersistenceService:294 ] - filter operator: EQ
23:58:56.441 [TRACE] [i.i.InfluxDBPersistenceService:295 ] - filter getBeginDate: null
23:58:56.441 [TRACE] [i.i.InfluxDBPersistenceService:296 ] - filter getEndDate: null
23:58:56.441 [TRACE] [i.i.InfluxDBPersistenceService:297 ] - filter getPageSize: 1
23:58:56.441 [TRACE] [i.i.InfluxDBPersistenceService:298 ] - filter getPageNumber: 0
23:58:56.441 [DEBUG] [i.i.InfluxDBPersistenceService:347 ] - got page size 1

The State is null but the Operator is not null. Why?

I will prepare a Pull Request.

theoweiss pushed a commit to theoweiss/openhab that referenced this issue Jan 16, 2015
theoweiss pushed a commit to theoweiss/openhab that referenced this issue Jan 16, 2015
teichsta added a commit that referenced this issue Jan 16, 2015
Influxdb persistence Bugfix for #1879
@teichsta teichsta added the bug label Jan 16, 2015
@teichsta teichsta added this to the 1.6.2 milestone Jan 16, 2015
@teichsta
Copy link
Member

fix merged into master

@hoalex
Copy link
Author

hoalex commented Jan 17, 2015

Thanks @theoweiss. Just downloaded the compiled .jar from CloudBees, restoreOnStartup now works perfectly 👍

@theoweiss
Copy link
Member

Cool, thanks for testing.

cdjackson added a commit to cdjackson/openhab1-addons that referenced this issue Jan 17, 2015
* master: (23 commits)
  Add support for Aeotec 5th generation keyfob
  influxdb persistence bugfix for issue 1225 openhab#1225: log warnings not errors
  influxdb persistence bugfix for issue 1879 openhab#1879 fixed page handling
  Set exeuction environment to 1.7 in XMPP action.
  influxdb persistence bugfix for issue 1879 openhab#1879
  Log if XMPP connection is encrypted or not
  Remove reconnectionFailed callback in XMPP action
  Improve connectionClosedOnError logging in XMPP action
  Let the server choose an XMPP resource for openhab
  Don't use reconnectionSuccessful() callback
  Add Smack sources to XMPP action
  Raise javac source/target level to 1.7 in XMPP action
  Fix for http binding not responding to wildcard outgoing commands
  Update to allow launch from Eclipse IDE
  added Wago Binding to build
  Bugfix openhab#1980: if refresh rate is not set in anel-configuration, the default rate for refresh thread (60s) was not read properly, so it used 0s instead. This caused the refresh rate to call 'execute()' every 0s which results in 100% cpu usage.
  Nibe heat pump: Fixed wrong compressor total operation time divider.
  Add a test for parsing exec binding IN config
  Use StringUtils.isEmpty in XMPP action
  Add xpp3 to Eclipse config of XMPP action
  ...
cdjackson added a commit to cdjackson/openhab1-addons that referenced this issue Jan 17, 2015
* zwave-database_updates: (24 commits)
  Add support for Aeotec 5th generation keyfob
  Add Linear PD300Z-2 openhab#2001
  influxdb persistence bugfix for issue 1225 openhab#1225: log warnings not errors
  influxdb persistence bugfix for issue 1879 openhab#1879 fixed page handling
  Set exeuction environment to 1.7 in XMPP action.
  influxdb persistence bugfix for issue 1879 openhab#1879
  Log if XMPP connection is encrypted or not
  Remove reconnectionFailed callback in XMPP action
  Improve connectionClosedOnError logging in XMPP action
  Let the server choose an XMPP resource for openhab
  Don't use reconnectionSuccessful() callback
  Add Smack sources to XMPP action
  Raise javac source/target level to 1.7 in XMPP action
  Fix for http binding not responding to wildcard outgoing commands
  Update to allow launch from Eclipse IDE
  added Wago Binding to build
  Bugfix openhab#1980: if refresh rate is not set in anel-configuration, the default rate for refresh thread (60s) was not read properly, so it used 0s instead. This caused the refresh rate to call 'execute()' every 0s which results in 100% cpu usage.
  Nibe heat pump: Fixed wrong compressor total operation time divider.
  Add a test for parsing exec binding IN config
  Use StringUtils.isEmpty in XMPP action
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants