Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-20079

When setting back the system time while mysqld is running, NOW() and UNIX_TIMESTAMP() results get stuck

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 10.3.4, 10.3.16, 10.4.6
    • 10.3.18, 10.4.8
    • Server
    • None

    Description

      Since MariaDB 10.3.4, when setting the system clock back in time (I tested by setting it back by 24h+), the NOW() and UNIX_TIMESTAMP() functions will not return the current, new, system time, but a fixed value from before when the system time was changed:

      MariaDB [(none)]> SELECT now(), sysdate(), unix_timestamp();
      +---------------------+---------------------+------------------+
      | now()               | sysdate()           | unix_timestamp() |
      +---------------------+---------------------+------------------+
      | 2019-07-16 18:36:29 | 2019-07-16 18:36:29 |       1563302189 |
      +---------------------+---------------------+------------------+
      1 row in set (0.001 sec)
       
      MariaDB [(none)]> \! date 07152000
      Mon Jul 15 20:00:00 UTC 2019
       
      MariaDB [(none)]> SELECT now(), sysdate(), unix_timestamp();
      +---------------------+---------------------+------------------+
      | now()               | sysdate()           | unix_timestamp() |
      +---------------------+---------------------+------------------+
      | 2019-07-16 18:36:31 | 2019-07-15 20:00:00 |       1563302191 |
      +---------------------+---------------------+------------------+
      1 row in set (0.000 sec)
       
      MariaDB [(none)]> SELECT sleep(2);
      +----------+
      | sleep(2) |
      +----------+
      |        0 |
      +----------+
      1 row in set (2.000 sec)
       
      MariaDB [(none)]> SELECT now(), sysdate(), unix_timestamp();
      +---------------------+---------------------+------------------+
      | now()               | sysdate()           | unix_timestamp() |
      +---------------------+---------------------+------------------+
      | 2019-07-16 18:36:31 | 2019-07-15 20:00:02 |       1563302191 |
      +---------------------+---------------------+------------------+
      

      Note how SYSDATE() correctly flips back to July 15th, while NOW() and UNIX_TIMESTAMP() are stuck with the last seen timestamp from 16th before the system time was set backwards with date

      Attachments

        Activity

          hholzgra Hartmut Holzgraefe created issue -
          elenst Elena Stepanova made changes -
          Field Original Value New Value
          Component/s Server [ 13907 ]
          Fix Version/s 10.3 [ 22126 ]
          Fix Version/s 10.4 [ 22408 ]
          Assignee Alexander Barkov [ bar ]

          serg This seems to be related to your commit ac2d4d49a041c4b0657d24a9b3b697cbcfe69790.
          Please have a look.

          bar Alexander Barkov added a comment - serg This seems to be related to your commit ac2d4d49a041c4b0657d24a9b3b697cbcfe69790. Please have a look.
          bar Alexander Barkov made changes -
          Assignee Alexander Barkov [ bar ] Sergei Golubchik [ serg ]
          serg Sergei Golubchik made changes -
          Priority Major [ 3 ] Critical [ 2 ]
          serg Sergei Golubchik made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          serg Sergei Golubchik made changes -
          Status In Progress [ 3 ] Stalled [ 10000 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 10.3.18 [ 23719 ]
          Fix Version/s 10.4.8 [ 23721 ]
          Fix Version/s 10.3 [ 22126 ]
          Fix Version/s 10.4 [ 22408 ]
          Resolution Fixed [ 1 ]
          Status Stalled [ 10000 ] Closed [ 6 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 98268 ] MariaDB v4 [ 156484 ]
          mariadb-jira-automation Jira Automation (IT) made changes -
          Zendesk Related Tickets 129754

          People

            serg Sergei Golubchik
            hholzgra Hartmut Holzgraefe
            Votes:
            0 Vote for this issue
            Watchers:
            4 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.