[dev.icinga.com #1954] Oracle date field doesn't respect Timezones #750
Comments
Updated by jmosshammer on 2011-09-26 13:57:49 +00:00 "This crashes all oracle installations as every timestamp works, but stuff like instance status or last check doesn't work" |
Updated by mfriedrich on 2011-09-26 14:03:52 +00:00 can you explain that by example? i don'get what you mean. |
Updated by jmosshammer on 2011-09-26 14:29:15 +00:00 We got several installation at our customers where we've got the problem that date information is delayed by 2 hours (Europe/Berlin is GMT+2, so data is stored in GMT+0, i.e. no timezone correction). This problem exists also when you access raw data via sqlplus |
Updated by tgelf on 2011-09-26 16:17:52 +00:00 As I also stumbled over this problem, I tried to dig a little bit deeper. The root cause of this issue is that we are currently using "DATE" for columns with date/time information. DATE isn't aware of timezones in Oracle. Therefore you can fiddle around with TZ-related environment- and/or session-settings as long as you want, it won't help. To get the same behaviour known from other IDO database backends we're probably forced to switch all "DATE" columns to "TIMESTAMP (0) WITH LOCAL TIMEZONE". Combined with a correct ORA_SDTZ environment setting (preferrably 'OS_TZ') this should IMO be the most elegant solution for this issue. Cheers, NB: I'm not an Oracle DBA, nor did I ever write any Oracle-related code. Someone should first check whether what I stated here is really true before blindly changing anything ;-) However I'm pretty sure that we definitively need to change something to get things right... |
Updated by mfriedrich on 2011-09-26 16:21:34 +00:00
well i'm no oracle dba either and i don't know what these changes will do on existing databases and how this complicates the overall setup. could you have look please? |
Updated by tgelf on 2011-09-26 17:05:26 +00:00 Hmmm... Redmine tried to "understand" SQL :p The column type should read TIMESTAMP ( 0 ) WITH LOCAL TIMEZONE |
Updated by Tommi on 2011-09-26 19:50:26 +00:00 there are several methods to include timezones. Because we are commited to Oracle 10gR2, the variants can be retrieved here: http://download.oracle.com/docs/cd/B19306\_01/server.102/b14225/ch4datetime.htm. In Oracle11 we have much more. -This will break current time setting behavior. Existing ido2db implementation relies on unix timestamps which should be UTC. There are 2 functions which converting timestamp to oracle date and back by counting seconds back to zero. If the timestamp is utc then the date is UTC and vice versa. My opinion in summary: |
Updated by mfriedrich on 2011-09-26 20:50:34 +00:00
ok, thanks for the explaination. i expected that to be a problem and possible break on compatibility. as the unixtimestamp being used remains utc, i thought that the icinga-web config is then doing some magic on getting the data correct? the classic ui also shows the data in utc if the icinga master is utc. it just must know about the timesetting which can be provided on a config way. |
Updated by jmosshammer on 2011-09-27 05:34:37 +00:00 The problem is that i (as a normal user/developer and not dba) expect a database to return correct timezone information according to the databases timezone layout - like mysql does and pgsql does (there it works like charm). ...and I don't think anyone other than icinga-web uses oracle as a db - at least I haven't found one. |
Updated by mfriedrich on 2011-09-27 07:07:37 +00:00 as a user i would expect the exact same value the inserting application Provider. isn't that correct with ido2db getting a unixtimestamp with localtime and inserting this? i do think that mysql and posthtesql behave badly on this situation, but correct me it i'm wrong... |
Updated by jmosshammer on 2011-09-27 07:26:20 +00:00 No, they don't - if the php timezone is set correctly everything works fine there (because datetime - otherwise I would agree that application level timezone correction is appropriate and add a handler that corrects it for all databases. I understand that this isn't a small change, but I'd really appreciate if we wouldn't have to focus on timezone correction for specific databases when the database provides facilities to manage these. |
Updated by mfriedrich on 2011-09-27 07:33:52 +00:00 to conclude with
if we can reproduce that behavior, we can discuss further. but with wild bug reports, it will be guessing all over. |
Updated by jmosshammer on 2011-09-27 07:38:40 +00:00 - ido2db debug
|
Updated by tgelf on 2011-09-27 10:30:00 +00:00 I'd suggest to change this issues topic to something like "IDO2Oracle handles timestamps different than other backends". IDO2DB uses a custom function unixts2date() and converts unix timestamps to string-like DATE columns (YES, I know they are more than just strings). Here is the proof that this "convert unix timestamp to date" job behaves different on Oracle than it does on MySQL: Oracle
MySQL
PosgreSQL is also using FROM_UNIXTIME. I didn't test it, but I guess it behaves like the MySQL variant. There are different ways of handling datetime values in a timezone-aware application:
Option ( C ) is IMO the worst solution and unfortunately for historical reason this is how things work in IDO2DB right now. Oracle differs slightly, it also does things the ( C ) way, but stores (string-like) DATEs for the UTC timezone instead of respecting your sessions environment. I guess no one here wants to touch all backends, this would cause a lot of work. As Oracle is "the new kid on the block" and the least used implementation I'd opt for making Oracle behave like the others do. Fortunately this wouldn't mean any schema/data changes. It would be enough to improve unixts2date() and date2unixts(). They should respect the session timezone used by the ido2db process, that way all backends would behave the same way. Would this be a viable solution? Cheers, |
Updated by Tommi on 2011-10-16 17:09:41 +00:00
Solution going implement: |
Updated by Tommi on 2011-10-28 11:11:05 +00:00
feature is implemented. Please check with my branch |
Updated by mfriedrich on 2011-11-15 17:12:55 +00:00 from my point of view it works fine, but more testing needed. |
Updated by jmosshammer on 2011-11-17 13:46:45 +00:00 When reading data from pgsql or oracle checks are now delayed by 1 hour if the local timezone is GMT+1: icinga=> SELECT last_check FROM icinga_hoststatus LIMIT 1;
|
Updated by Tommi on 2011-11-17 16:46:23 +00:00 which timezone is set on icinga host? if Timezone is UTC: is the system time really UTC? Pls. open oracle sqlplus, connect to icinga schema and provide output of following sql: for postgresql: select localtimestamp; |
Updated by jmosshammer on 2011-11-18 08:57:52 +00:00 PGSQLicinga=> select localtimestamp;
|
Updated by Tommi on 2011-11-19 20:40:01 +00:00 looks like extended development agent version string "1.6.0-dev" is too long for table conninfo field agent_version =varchar2(8), therefore the db_hello terminates here and will omit the following alter session part, which is responsible to set session timezone correct. This issue will not happen in production(string is shorter), but i recommand to extend this field to varchar2(10). |
Updated by Tommi on 2011-11-21 19:03:20 +00:00
confirmed by marius. agent_version issue will be tracked with #2104 |
Updated by mfriedrich on 2014-12-08 14:37:25 +00:00
|
This issue has been migrated from Redmine: https://dev.icinga.com/issues/1954
Created by jmosshammer on 2011-09-26 13:53:53 +00:00
Assignee: Tommi
Status: Resolved (closed on 2011-11-21 19:03:20 +00:00)
Target Version: 1.6
Last Update: 2014-12-08 14:37:25 +00:00 (in Redmine)
ido2db doesn't respect timezones when writing to the database. Date fields are always delayed.
I think oracle's 'date' doesn't know timezones.
This crashes all oracle installations as every timestamp works, but stuff like instance status or last check doesn't work
Changesets
2011-10-27 20:27:42 +00:00 by Tommi c62937e
2011-11-16 15:31:06 +00:00 by mfriedrich de3e6ea
2011-11-16 17:27:15 +00:00 by mfriedrich 515b200
2011-11-21 20:50:47 +00:00 by Tommi ce3cfbc
Relations:
The text was updated successfully, but these errors were encountered: