How to resolve "An exception occurred when executing the following query:Cause: HOUR_OF_DAY: 2 -> 3 " when executing queries against MySQL?

How to resolve "An exception occurred when executing the following query:Cause: HOUR_OF_DAY: 2 -> 3 " when executing queries against MySQL?

book

Article ID: KB0071356

calendar_today

Updated On:

Products Versions
TIBCO Data Virtualization -

Description

TDV shows an error when trying to execute a query that fetches a DATETIME value that is within the DST lost hour using MySQL adapter.

This has been seen after:
1. Changing the MySQL database time zone
2. Upgrading the MySQL adapter from 5.x to 8.x

The error will display an exception with the following cause: HOUR_OF_DAY: 2 -> 3

The exception "HOUR_OF_DAY: <<x>> → <<y>>" occurs when the DATETIME <<x>> does not exist due to a daylight saving time (DST), when the time <<x>> does not exist as it was moved to <<y>>.

The root cause of this error is actually because of the difference in time zones of the instances and mysql jdbc adapters 8.0 and above see certain dates as invalid when migrating from data that observes daylight saving to an instance that does not observe daylight saving. For example, Sunday March 13, 2023 within the hour of 2am to 3am is correct for UTC time but it does not translate to a valid time in servers that do observe daylight saving because the hour was lost in Time zones observing Daylight saving. 

Resolution

This is a well known and documented limitation in MySQL adapter, the information about the bug can be found here:
https://bugs.mysql.com/bug.php?id=96276

There are some workarounds for this, that need to be implemented by the DBA in charge of the MySQL instance.

1. Its possible to set the server time zone of the instance that does observe daylight saving to UTC  Using serverTimezone=UTC
2. Turning on leniency in the Calendar used by SqlTimestampValueFactory
3. Find the records with invalid dates and manually change the invalid dates and hours to a corresponding time that would be valid. 

Some workarounds on the TDV client side may be :
1. To use a MySQL adapter 5.x (Since this is a limitation with MySQL adapter 8.x)
2. Changing the time zone used by TDV Server as described in https://support.tibco.com/s/article/How-to-change-the-timezone-on-TIBCO-Data-Virtualization-Server-for-Windows

Issue/Introduction

TDV shows an error when trying to execute a query that fetches a DATETIME value that is within the DST lost hour using MySQL adapter.