LocalDateTest failures on MySQL

Description

writeThenRead, nativeWriteThenRead and writeThenNativeRead tests are all failing with errors similar to:

java.lang.AssertionError: Values written by Hibernate ORM should match the original value (same day, hour, ...) expected:<2018-03-25> but was:<2018-03-24>

Environment

None

Activity

Show:
Yoann Rodière
August 26, 2019, 11:49 AM

Neither am I.

There might be one explanation... The test suite changes the default JVM time zone multiple times during its execution, to simulate different real-world scenarios. However, the MySQL JDBC driver caches the JVM time zone in a static variable, which might introduce side-effects between tests.

Could you please try setting the cacheDefaultTimezone JDBC driver property to false, to rule out the problem mentioned above?

The setting is provided through the JDBC URL. For example, instead of this:

Use this:

Yoann Rodière
August 27, 2019, 7:38 AM

Another potential explanation: the legacy date-time code in MySQL ConnectorJ 5.x is notoriously buggy when it comes to handling timezones. Setting useLegacyDatetimeCode=false could solve a lot of problems.

So instead of this:

Use this:

Yoann Rodière
August 27, 2019, 7:54 AM

Digging up, you're using MySQL ConnectorJ 8.x, whereas our tests use 5.x. These version have vastly different date/time handling. I'll upgrade our tests.

Yoann Rodière
August 27, 2019, 9:41 AM

This is caused by https://bugs.mysql.com/bug.php?id=91112.

In essence, MySQL ConnectorJ 8.x applies timezone conversion to dates before writing them (which might change the exact date), then truncates the time part when storing it in the database. So when it retrieves the date later, there is no way it can convert it back to the original date.

Apparently they consider it's not a bug, because the JDBC spec does not state explicitly what they are supposed to do. Never mind that all other JDBC drivers do it differently...

Anyway, if they consider that's how things are supposed to work, there's not much we can do to work around the problem. I'll disable the tests.

Gail Badner
September 12, 2019, 2:16 AM

Fixed in master and 5.3 branches.

Assignee

Yoann Rodière

Reporter

Peter Mackay

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

backportDecision

None

Components

Priority

Major
Configure