Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-1026

timezone=auto option failure on non-fixed-offset zone machine

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 3.0.9, 3.1.0
    • 3.0.10, 3.1.1
    • Other
    • None
    • 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

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            awaizman Assaf Waizman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.