[CONJ-1026] timezone=auto option failure on non-fixed-offset zone machine Created: 2022-11-20  Updated: 2023-01-09  Resolved: 2023-01-09

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 3.0.9, 3.1.0
Fix Version/s: 3.0.10, 3.1.1

Type: Bug Priority: Major
Reporter: Assaf Waizman Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

maria jdbc client 3.1.0 (happen with all 3.x versions)
ubuntu 18
mariadb official docker



 Description   

When running mariadb server on UTC timezone machine (for my test i run mariadb docker image which run in UTC), the timezone=auto jdbc option seems to fail.
My client is running on a machine with timezone Asia/Jerusalem, this timezone is not one with fixed offset (daylight saving)

TimeZone.getDefault().getRules().isFixedOffset() = false

In this case, the org.mariadb.jdbc.client.impl.StandardClient.java throws the following exception:

java.sql.SQLException: (conn=1157) Setting configured timezone 'auto' fail on server.
21:47:26      Look at https://mariadb.com/kb/en/mysql_tzinfo_to_sql/ to load tz data on server, or set timezone=disable to disable setting client timezone.

Observing the code, it seems like a bug in how the client handles non-fixed-offset timezone:

if (mustSetTimezone) {
  if (clientZoneId.getRules().isFixedOffset()) {
    ZoneOffset zoneOffset = clientZoneId.getRules().getOffset(Instant.now());
    if (zoneOffset.getTotalSeconds() == 0) {
      // specific for UTC timezone, server permitting only SYSTEM/UTC offset or named time
      // zone
      // not 'UTC'/'Z'
      sessionCommands.add("time_zone='+00:00'");
    } else {
      sessionCommands.add("time_zone='" + zoneOffset.getId() + "'");
    }
  } else {
-->    sessionCommands.add("time_zone='" + conf.timezone() + "'");  <--
  }
}

in case the timezone is not fixedoffset, the appended session command will be time_zone=auto, which is not a valid timezone. Thus the server return with error.

server variables:
GLOBAL time_zone: SYSTEM
GLOBAL system_time_zone: UTC

would u please verify?

Thanks


Generated at Thu Feb 08 03:20:04 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.