[MDEV-20079] When setting back the system time while mysqld is running, NOW() and UNIX_TIMESTAMP() results get stuck Created: 2019-07-16  Updated: 2020-08-25  Resolved: 2019-09-04

Status: Closed
Project: MariaDB Server
Component/s: Server
Affects Version/s: 10.3.4, 10.3.16, 10.4.6
Fix Version/s: 10.3.18, 10.4.8

Type: Bug Priority: Critical
Reporter: Hartmut Holzgraefe Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: 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



 Comments   
Comment by Alexander Barkov [ 2019-08-30 ]

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

Generated at Thu Feb 08 08:56:34 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.