Bug 750883 - Change of Daylight Saving Time not saved
Summary: Change of Daylight Saving Time not saved
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: systemd
Version: 16
Hardware: x86_64
OS: Unspecified
unspecified
high
Target Milestone: ---
Assignee: systemd-maint
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-11-02 17:07 UTC by Mattia Verga
Modified: 2014-06-19 22:59 UTC (History)
18 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-06-19 22:59:10 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
output of /var/log/messages (1.20 KB, text/plain)
2011-11-02 17:19 UTC, Mattia Verga
no flags Details

Description Mattia Verga 2011-11-02 17:07:06 UTC
Description of problem:
Since the change from Daylight Saving Time to the CET I see that Fedora starts with clock set to the old timezone (+2 UTC) and change to CET when I'm already entered in the desktop environment (KDE). If I reboot the PC I can see that in BIOS the change of time is not saved.
When Fedora starts some services are not happy with the clock being turned backwards. For instance in BOINC I can see in the logs:

mer 02 nov 2011 18:57:25 CET |  | System clock was turned backwards; clearing timeouts

And it blocks computations for an hour.


Version-Release number of selected component (if applicable):
cronie-1.4.8-10.fc16.x86_64


How reproducible:
Always


Steps to Reproduce:
1. Set the clock to 18.00 when in DST
2. Change the date to be no more in DST
3. Reboot the PC: you enter the desktop environment with 18.00 and after some second it changes to 17.00
  
Actual results:
New time not saved in BIOS

Expected results:
Time saved in BIOS or change before other services starts

Comment 1 Marcela Mašláňová 2011-11-02 17:16:36 UTC
I don't see how this is related to cronie. Did you mentioned chrony? Time could be automatically set be chrony or ntpdate, which override your KDE settings.

Comment 2 Mattia Verga 2011-11-02 17:19:14 UTC
Yes, sorry... I was just adding the note that I think I set the wrong component. Looking in /var/log/messages I can see chrony.
Can you reassign the bug, please?
Thank you

chrony-1.26-3.20110831gitb088b7.fc16.x86_64

Comment 3 Mattia Verga 2011-11-02 17:19:48 UTC
Created attachment 531402 [details]
output of /var/log/messages

Comment 4 Miroslav Lichvar 2011-11-03 06:16:24 UTC
NTP doesn't know anything about timezones. This looks like RTC is in local time and hwclock --systohc is not called on shutdown/reboot. I'm not sure what is supposed to do that nowadays, let's try systemd.

Comment 5 Kay Sievers 2011-11-03 11:35:32 UTC
It's probably this:
  https://bugzilla.redhat.com/show_bug.cgi?id=749516#c25

Comment 6 Miroslav Lichvar 2011-11-03 12:12:33 UTC
Interesting. What system component is supposed to monitor changes in DST and sync the RTC if it's on local time? Or is now only RTC on UTC supported?

I like the idea of not doing the sync on shutdown as it allows chrony to track the RTC drift and correct it on boot.

Comment 7 Lennart Poettering 2011-11-03 12:48:29 UTC
Having the RTC in local time is broken in many ways and exists only for compatibility with Windows. If enabled, for summer time changes only one OS can be in charge, since the OS has to remember that it did the summer time change, in order not to repeat the adjustment on subsequent boots. Since the only use of this feature is compatibility with Windows anyway, that one OS in charge should be Windows, and not us. hence we are doing exactly the right thing here: leave the RTC completely untouched, and let Windows do its work.

Or with other words: you can choose between a) automatic timezone changes from Linux and b) compatibility with Windows, but not have both. For a) enable UTC RTC time. For b) enable LOCAL RTC time. if you choose b) then it's Windows' job to change the summer time.

Comment 8 Tomas Mraz 2011-11-03 13:05:36 UTC
What's the problem _on a system using NTP_ to sync the RTC clock on boot if the DST changed recently and "surprisingly" the time obtained from NTP differs from the RTC clock time by one hour?

Comment 9 Kay Sievers 2011-11-03 13:27:29 UTC
(In reply to comment #8)
> What's the problem _on a system using NTP_ to sync the RTC clock on boot
> if the DST changed recently and "surprisingly" the time obtained from
> NTP differs from the RTC clock time by one hour?

On NTP systems, the kernel automatically syncs to the RTC every 11 minutes.

Comment 10 Tomas Mraz 2011-11-03 13:32:00 UTC
Apparently that is not happening on the reporter's system.

Comment 11 Miroslav Lichvar 2011-11-03 13:45:41 UTC
(In reply to comment #9)
> On NTP systems, the kernel automatically syncs to the RTC every 11 minutes.

In the 11 minute mode kernel syncs only within 30 minutes as it doesn't know about timezones or DST.

Chrony can be configured to track the RTC (the 11 minute mode is disabled) and RTC can be synced by the "chronyc trimrtc" command, but nothing else should be touching the RTC which is hard to guarantee.

Comment 12 Michal Schmidt 2011-11-03 15:40:49 UTC
> In the 11 minute mode kernel syncs only within 30 minutes as it doesn't know
> about timezones or DST.

Those like me, who did not know about this, see the kernel function:
http://lxr.linux.no/#linux+v3.1/arch/x86/kernel/rtc.c#L41

Comment 13 Petr Machata 2011-11-03 15:56:26 UTC
(In reply to comment #11)
> (In reply to comment #9)
> > On NTP systems, the kernel automatically syncs to the RTC every 11 minutes.
> 
> In the 11 minute mode kernel syncs only within 30 minutes as it doesn't know
> about timezones or DST.

Just FYI, some rare zones actually shift their DST time only by 0:30.  Currently it's only Lord Howe Island in Australia, a couple more such zone existed at various points in the past.

Comment 14 Tomas Mraz 2011-11-03 15:57:26 UTC
Reopening. As this is clear regression. And no nobody wants to fix unfixable problems just please do not break things that worked before fine. If this sync should be done by chrony now let's be it.

Comment 15 Kay Sievers 2011-11-03 16:49:18 UTC
That's not right, it never worked properly in dual OS boot environments.
We did not break anything that was working, we just don't pretend we can
solve that problem.

Comment 16 Tomas Mraz 2011-11-03 17:06:15 UTC
Yes, it never worked _fully_ correctly as this is not possible without cooperation with Windows. But it worked at least partially correctly on machines that are only occasionally booted into Windows. And this is now broken.

Comment 17 Kay Sievers 2011-11-03 17:14:36 UTC
It depends on which detail you focus. I would state it's much less broken
now than it was. It's just unfixable, so we should not try to pretend we
know how it's used, and leave it alone instead of breaking things in the
intention to make stuff working.

Comment 18 Bill Nottingham 2011-11-03 17:17:10 UTC
The issue is KDE not syncing the change to the hardware clock when the time is set in KDE? That's already being fixed. What else is wanted here?

Comment 19 Mattia Verga 2011-11-03 17:53:34 UTC
(In reply to comment #18)
> The issue is KDE not syncing the change to the hardware clock when the time is
> set in KDE? That's already being fixed. What else is wanted here?

This is not related to KDE (and to the other bug pointed out from Kay Sievers).
After the change from DST to no DST I can see my system doing:
1. Boot Fedora and all services

2. Start chronyd and sync the clock with ntp:
Nov  3 19:41:57 Betelgeuse chronyd[1050]: Selected source 93.62.230.241
Nov  3 19:41:57 Betelgeuse chronyd[1050]: System clock wrong by -3599.169419 seconds, adjustment started
Nov  3 18:41:58 Betelgeuse chronyd[1050]: System clock was stepped by -3599.169 seconds

3. Some service (the most important is sendmail) don't react well to this 
Nov  3 18:42:55 Betelgeuse systemd[1]: sendmail.service operation timed out. Terminating.
Nov  3 18:42:55 Betelgeuse systemd[1]: Unit sendmail.service entered failed state.

4. The new time is not saved to BIOS and after a reboot it all starts again

I would expect:
1. Chronyd is called before other services that aren't needed by chronyd itself.
2. The new time should be saved to BIOS when chronyd use ntp to sync the clock

Comment 20 Lennart Poettering 2011-11-03 19:32:11 UTC
Guys, the thing here is that there are two broken ways to handle RTC in local time: i.e. where userspace syncs the system clock to RTC on shutdown, and where it doesn't. Both ways are broken: The first choice breaks the DST change Windows will do on the next boot. The second choice will forget never do automatic DST changes on Linux and the clock is will continue to be wrong on each subsequent Linux boot.

Given that local RTC is a hack to be nice to Windows I'm strongly of the opinion that we shouldn't muck with Windows' DST logic if it is enabled, and hence stay away from the RTC. If you want Windows compatibility you get Windows compatibility -- and nothing else. If you are willing to pass control over the RTC to Windows, then pass it the control to the RTC, don't come up with something half-baked, where you muck with it too in a away that just confuses Windows.

On RTC in UTC we have very little reason to believe that the system clock was any more accurate than the RTC unless NTP is used. If NTP is used the kernel will write the system clock to the RTC every 11 minutes anyway, hence there's no point at all to sync system clock to RTC at all. And that's why we don't do that.

So, closing again. I see nothing here that systemd could do any better.

Comment 21 Mattia Verga 2011-11-04 06:59:28 UTC
Ok, a couple of questions again: you said "If NTP is used the kernel
will write the system clock to the RTC every 11 minutes", but on my system this is clearly not happening. Should I fill a new bug against kernel? In this case is this a Fedora thing and I should open the bug in redhat bugzilla, or is a standard kernel feature and I should report to kernel?

Another bug I'm seeing is that Sendmail crashes and it should be manually restarted if the clock is turned backwards 1 hour. Does it makes sense opening a new bug against sendmail? Or is systemd that should periodically check the status of critical system services and try to restart them if they're dead?

Thank you.

Comment 22 Michal Schmidt 2011-11-04 10:48:18 UTC
(In reply to comment #20)
> If NTP is used the kernel will write the system clock to the RTC every
> 11 minutes anyway, hence there's no point at all to sync system clock
> to RTC at all.

Lennart,
as comment #11 tried to explain, the kernel's periodic 11-minutes sync does not write the full time to the RTC, it merely corrects for errors within a window of modulo 30 minutes. So it only touches minutes and seconds in the RTC, it does not fix the hours.
Doesn't that break your assumptions?

Does anaconda even default to setting "RTC runs in UTC"? I don't remember.

Comment 23 Thomas L. Shinnick 2011-11-14 17:43:04 UTC
Please see bug https://bugzilla.redhat.com/show_bug.cgi?id=753642
which does not involve daylight/standard time changes, but rather 
a simple install setting timezone to CST and then use.

chronyd's adjusting the time drastically during boot catches some 
components seeing both the boot time value and then another new
value some (6) hours difference apart.  Wreaks havoc on DHCP lease
timestamps, for instance.

Comment 24 Tomas Mraz 2011-11-15 11:42:33 UTC
It is now apparent that syncing the system clock to hw clock on system shutdown increases the system robustness regardless of whether the hw clock is UTC or not. Although it does not solve the problems in a "perfect" way remember please that perfect is the enemy of the good.
Reopening.

Comment 25 Miroslav Lichvar 2011-11-15 11:51:29 UTC
Also, there seems to be a problem with the kernel RTC synchronization, see bug #753487.

Comment 26 Bernhard M. Wiedemann 2011-12-06 18:14:40 UTC
I hit this one-hour-off problem on two different openSUSE-12.1 systems with systemd not setting RTC on shutdown anymore. None of the two systems actually runs Windows and at least one even had the RTC set to UTC mode.


When you only rely on the kernel to update the RTC, it will remain wrong, whenever it was wrong by more than 15 or 30 minutes (e.g. skewed after long time off or without ntp)

so hwclock needs to be written - and before shutdown is the best time for it, because ntp will have run for a long time and be well synchronized.

The problem with Windows is that a) it does not use RTC as UTC and b) it changes the clock by 1 hour without actually knowing anything about the real time... but I feel that this should be fixed by MICROS~1 rather than all Linux users suffering from the workaround.

Comment 27 Kay Sievers 2011-12-06 20:38:02 UTC
That sounds like a setting for ntp or crony. Systemd should stay out of
the game fiddling with the RTC without knowing the current state of the
time sync. It as no idea if NTP has successful run during bootup.

Comment 28 Bernhard M. Wiedemann 2011-12-18 19:07:35 UTC
filed against openSUSE's NTP: https://bugzilla.novell.com/show_bug.cgi?id=737518

Comment 29 Jóhann B. Guðmundsson 2012-01-29 15:34:18 UTC
Given comment 27 I'm closing this as notabug.

Please open new bug against ntp or chrony.

Thanks

Comment 30 Gene Snider 2012-03-26 22:53:53 UTC
I tell Windows to use UTC on my dual boot machines, it's not that hard.  Then the problem disappears.  :)

Gene

Comment 31 Miroslav Lichvar 2012-09-20 14:33:37 UTC
FYI, a new discussion about this problem is taking place in bug #816752.

Comment 32 Hedayat Vatankhah 2013-09-23 08:19:57 UTC
I wonder how it is not a bug. DST changes are not saved, and AFAIK it is not done by chrony or ntp

Comment 33 Hedayat Vatankhah 2013-09-23 08:29:44 UTC
This is certainly a bug. The component might be wrong, but it is a bug.

My system RTC is set to local time. I do NOT synchronize my time with network. Two days ago the system time changed by one our because we are no longer in DST. that was fine. But unfortunately, the change was not saved to RTC. My system clock was correct, I shutdown my system. I turned it on afterwards, but the time was incorrect. Whoever has applied the DST settings must have changed RTC too. Would you please suggest the correct component instead of closing the bug?

Comment 34 Lennart Poettering 2014-06-19 22:59:10 UTC
Newer kernels do a full RTC sync these days in 11min mode, I figure this can be closed now.


Note You need to log in before you can comment on or make changes to this bug.