Closed mhilbush closed 5 years ago
I can make the exception go away if I change the database URL in mysql.cfg
from this
url=jdbc:mysql://localhost:3306/openhab
to this
url=jdbc:mysql://localhost:3306/openhab?serverTimezone=EST (Eastern Standard Time)
The error returns if I set the URL to this
url=jdbc:mysql://localhost:3306/openhab?serverTimezone=EDT (Eastern Daylight Time)
Interestingly, it is no longer DST here in the US, so I'm not sure where the EDT is coming from when using the first URL above.
👍 I will check what I can configure in java but this should help some people out. Can you check whether the MySQL config contains a reference to EDT?
It does not contain EDT.
# the database url like 'jdbc:mysql://<host>:<port>/<database>' (without quotes)
url=jdbc:mysql://localhost:3306/openhab
# the database user
user=openhab
# the database password
password=XXXXXXX
# the reconnection counter
reconnectCnt=1
# the connection timeout (in seconds)
#waitTimeout=
I meant the config of the MySQL server
Oops, sorry.
Nothing in any of the config files in /etc/mysql
. Anywhere else I should look?
Last option could be your OS?
/etc/timezone
contains
America/New_York
The box has been up for 52 days (DST ended a little over a week ago), so I'm going to reboot it.
Unfortunately, if the problem goes away, I may not be able to recreate it.
Sure enough, after a reboot the problem went away.
In hindsight, I should've restarted the mysql server to see if the problem would clear. ☹️
I have another system that's been up for 255 days. Let me see how that one's behaving...
I was able to recreate it on the system that was up for 255 days. A restart of the mysql server cleared the error.
So, it appears that the upgrade to the connector exposed an issue that can be cleared by restarting the mysql server.
I'm going to close this. We can reference this issue if anyone else stumbles across the problem.
FTR, I also have a system whose uptime was only 5 days (i.e. it was rebooted after the DST change). After installing build 1423, it did not exhibit the issue.
So I think that pretty much seals it.
Thanks for looking into it and documenting your findings!
Could you write a suggestion for the README of the mysql bundle? It would maybe be a more sensible place to look then a closed issue. Thanks!
Sure. Were you thinking something like there being a possible need to restart the mysql server in the event of an error message in the log about an unrecognized server timezone value?
Yes and maybe a reference to the serverTimezone parameter? Could be useful as well!
This is still there.
==> openhab.log <==
2019-03-15 07:39:35.892 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Failed connecting to the SQL database using: driverClass=com.mysql.jdbc.Driver, url=jdbc:mysql://127.0.0.1:3306/openHab, user=openHab
java.sql.SQLException: The server time zone value 'EDT' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
MySQL by default uses SYSTEM for time_zone
, which means it gets it from the OS (Ubuntu 18.04).
This is fresh install on a new server.
$ openhab-cli info
Version: 2.5.0-SNAPSHOT (#1555)
User: openhab (Environment Variable Set)
User Groups: openhab tty dialout audio bluetooth
Note that we are now back to EDT as of last Sunday (it was EST before):
$ timedatectl status | grep "Time zone"
Time zone: America/New_York (EDT, -0400)
Changing the configuration to
url=jdbc:mysql://127.0.0.1:3306/openHab?serverTimezone=EST (Eastern Standard Time)
as shown above gets a different error:
==> openhab.log <==
2019-03-15 07:53:40.011 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Failed connecting to the SQL database using: driverClass=com.mysql.jdbc.Driver, url=jdbc:mysql://127.0.0.1:3306/openHab?serverTimezone=EST (Eastern Standard Time), user=openHab
java.sql.SQLException: No timezone mapping entry for 'EST (Eastern Standard Time)'
If I manually configure MySQL to use UTC instead, OpenHAB then connects fine;
SET time_zone = '+00:00';
That however, causes the time to be recorded in UTC even though the configuration says to use "local" time
# Use MySQL Server time to store item values (=false) or use openHAB Server time (=true).
# For new installations, its recommend to set "localtime=true".
# (optional, defaults to false)
localtime=true
(Item2 == Sun elevation)
$ date
Fri Mar 15 08:21:03 EDT 2019
mysql> SELECT * FROM `Item2` LIMIT=10;
+---------------------+-------------------+
| Time | Value |
+---------------------+-------------------+
| 2019-03-15 12:08:40 | 7.570988932723573 |
| 2019-03-15 12:09:03 | 7.570988932723573 |
| 2019-03-15 12:09:38 | 7.765190239551979 |
| 2019-03-15 12:10:02 | 7.765190239551979 |
| 2019-03-15 12:10:38 | 7.965844045811203 |
| 2019-03-15 12:11:01 | 7.965844045811203 |
| 2019-03-15 12:11:38 | 8.166377760499284 |
| 2019-03-15 12:12:02 | 8.166377760499284 |
| 2019-03-15 12:12:38 | 8.366830272647348 |
| 2019-03-15 12:13:01 | 8.366830272647348 |
+---------------------+-------------------+
10 rows in set (0.00 sec)
Only after all of the above did I notice this is the openhab1 repo. I'm using openhab2 as shown above. Sorry for the mess...
I ran into the same issue when the time changed this week. There clearly is a problem with the MySQL driver in OH 2.4 that causes an error when the timezone changes between standard and daylight saving time (or vice versa). Restarting my Docker Swarm services for MySQL and openHAB did not fix the problem.
For me (America/New_York
system timezone), it looks like it's fixed by adding ?serverTimezone=EST5EDT
to the end of the JDBC URL in services/mysql.cfg
and leaving the MySQL server alone (which uses SYSTEM
).
Just installed build 1423 and I'm seeing a mysql exception during startup.
I'm on this version of mysql Server version: 5.7.23-0ubuntu0.16.04.1 (Ubuntu)
@martinvw Possibly related to this PR? https://github.com/openhab/openhab1-addons/pull/5699