Обсуждение: What does PostgreSQL do when time goes backward?

Поиск
Список
Период
Сортировка

What does PostgreSQL do when time goes backward?

От
John Hasler
Дата:
How does PostgreSQL react to time being stepped at bootup?  My Chrony
NTP package might cause it to do so on rare occasions when the hardware
clock is way off.  This would only happen during bootup.
-- 
John Hasler 
jhasler@newsguy.com
Elmwood, WI USA


Re: What does PostgreSQL do when time goes backward?

От
Frank Bax
Дата:
John Hasler wrote:
> How does PostgreSQL react to time being stepped at bootup?  My Chrony
> NTP package might cause it to do so on rare occasions when the hardware
> clock is way off.  This would only happen during bootup.


My ntp client changes clock (by small amount) at any time:

Jul 25 05:29:38 bax ntpd[10269]: adjusting local clock by 0.098724s
Jul 25 05:31:43 bax ntpd[10269]: adjusting local clock by 0.038991s
Jul 25 06:13:38 bax ntpd[10269]: adjusting local clock by -0.037131s
Jul 25 15:01:52 bax ntpd[10269]: adjusting local clock by -0.112429s


Re: What does PostgreSQL do when time goes backward?

От
Kenneth Marshall
Дата:
On Wed, Aug 04, 2010 at 07:20:31AM -0400, Frank Bax wrote:
> John Hasler wrote:
>> How does PostgreSQL react to time being stepped at bootup?  My Chrony
>> NTP package might cause it to do so on rare occasions when the hardware
>> clock is way off.  This would only happen during bootup.
>
>
> My ntp client changes clock (by small amount) at any time:
>
> Jul 25 05:29:38 bax ntpd[10269]: adjusting local clock by 0.098724s
> Jul 25 05:31:43 bax ntpd[10269]: adjusting local clock by 0.038991s
> Jul 25 06:13:38 bax ntpd[10269]: adjusting local clock by -0.037131s
> Jul 25 15:01:52 bax ntpd[10269]: adjusting local clock by -0.112429s
>

PostgreSQL does not use system time to track transactions so
you should be good. Also, these types of clock changes by ntpd
use the adjtime() system call which either slows or speeds the
system clock to make the adjustment over a period of time so
it should be minimally disruptive. These do seem to be larger
values than you might expect from a clock conditioned with ntpd.
Is it a VM or is there something going on that would stop or
suspend your system?

Cheers,
Ken


Re: What does PostgreSQL do when time goes backward?

От
John Hasler
Дата:
I wrote:
> How does PostgreSQL react to time being stepped at bootup?  My Chrony
> NTP package might cause it to do so on rare occasions when the
> hardware clock is way off.  This would only happen during bootup.

Ken writes:
> PostgreSQL does not use system time to track transactions so you
> should be good.

Thank you.

> Also, these types of clock changes by ntpd use the adjtime() system
> call which either slows or speeds the system clock to make the
> adjustment over a period of time so it should be minimally disruptive.

This is about Chrony <http://www.chrony.tuxfamily.org>, an alternative
ntp implementation.  In any case, both chronyd and ntpd can step the
clock (possibly backwards) at bootup under some rare circumstances.

Frank writes:
> My ntp client changes clock (by small amount) at any time:
> Jul 25 05:29:38 bax ntpd[10269]: adjusting local clock by 0.098724s
> Jul 25 05:31:43 bax ntpd[10269]: adjusting local clock by 0.038991s
> Jul 25 06:13:38 bax ntpd[10269]: adjusting local clock by -0.037131s
> Jul 25 15:01:52 bax ntpd[10269]: adjusting local clock by -0.112429s

Ken writes:
> These do seem to be larger values than you might expect from a clock
> conditioned with ntpd.  Is it a VM or is there something going on that
> would stop or suspend your system?

There is certainly something wrong there.
-- 
John Hasler 
jhasler@newsguy.com
Elmwood, WI USA


Re: What does PostgreSQL do when time goes backward?

От
Steve Wampler
Дата:
John Hasler wrote:

> Frank writes:
>> My ntp client changes clock (by small amount) at any time:
>> Jul 25 05:29:38 bax ntpd[10269]: adjusting local clock by 0.098724s
>> Jul 25 05:31:43 bax ntpd[10269]: adjusting local clock by 0.038991s
>> Jul 25 06:13:38 bax ntpd[10269]: adjusting local clock by -0.037131s
>> Jul 25 15:01:52 bax ntpd[10269]: adjusting local clock by -0.112429s
> 
> Ken writes:
>> These do seem to be larger values than you might expect from a clock
>> conditioned with ntpd.  Is it a VM or is there something going on that
>> would stop or suspend your system?
> 
John writes:
> There is certainly something wrong there.

I saw very bad clock performance on one Linux box I had (dual-single core
AMD cpus, no VMs), even with NTP, until I changed the clocksource kernel
parameter to hpet.  Unfortunately (or fortunately) I no longer have that box.

-- 
Steve Wampler -- swampler@noao.edu
The gods that smiled on your birth are now laughing out loud.


Re: What does PostgreSQL do when time goes backward?

От
Frank Bax
Дата:
John Hasler wrote:
> Frank writes:
>> My ntp client changes clock (by small amount) at any time:
>> Jul 25 05:29:38 bax ntpd[10269]: adjusting local clock by 0.098724s
>> Jul 25 05:31:43 bax ntpd[10269]: adjusting local clock by 0.038991s
>> Jul 25 06:13:38 bax ntpd[10269]: adjusting local clock by -0.037131s
>> Jul 25 15:01:52 bax ntpd[10269]: adjusting local clock by -0.112429s
> 
> Ken writes:
>> These do seem to be larger values than you might expect from a clock
>> conditioned with ntpd.  Is it a VM or is there something going on that
>> would stop or suspend your system?
> 
> There is certainly something wrong there.


System is not a VM; it runs 24/7 hosting for a few simple domains.  It 
runs OpenBSD, not Linux.  I believe OpenBSD has it's own ntpd 
implementation.  I read once that the amount of time mentioned is how 
much time clock needs to be changed, not how much the clock will 
actually be changed.  I know nothing about ntpd internals; thanks for 
letting me hijack this thread.  The log messages may be out-of-context, 
since I excluded frequency changes.  Still something wrong?

Jul 25 00:13:25 bax ntpd[10269]: adjusting local clock by -0.038453s
Jul 25 00:42:25 bax ntpd[10269]: adjusting clock frequency by -10.296223 
to -20.774345ppm
Jul 25 02:38:31 bax ntpd[10269]: adjusting local clock by 0.039182s
Jul 25 04:56:29 bax ntpd[10269]: adjusting clock frequency by 3.332808 
to -17.441537ppm
Jul 25 05:29:38 bax ntpd[10269]: adjusting local clock by 0.098724s
Jul 25 05:31:43 bax ntpd[10269]: adjusting local clock by 0.038991s
Jul 25 06:13:38 bax ntpd[10269]: adjusting local clock by -0.037131s
Jul 25 08:26:12 bax ntpd[10269]: adjusting clock frequency by -5.876526 
to -23.318063ppm
Jul 25 11:07:08 bax ntpd[10269]: adjusting clock frequency by 16.235236 
to -7.082827ppm
Jul 25 15:01:52 bax ntpd[10269]: adjusting local clock by -0.112429s
Jul 25 15:38:06 bax ntpd[10269]: adjusting clock frequency by -9.112840 
to -16.195667ppm
Jul 25 20:42:03 bax ntpd[10269]: adjusting clock frequency by 1.838351 
to -14.357316ppm
Jul 26 05:57:41 bax ntpd[10269]: adjusting clock frequency by -0.485347 
to -14.842663ppm
Jul 26 15:48:01 bax ntpd[10269]: adjusting clock frequency by -0.130635 
to -14.973298ppm
Jul 26 23:51:48 bax ntpd[10269]: adjusting clock frequency by -0.632588 
to -15.605885ppm
Jul 27 09:14:44 bax ntpd[10269]: adjusting clock frequency by 0.761208 
to -14.844677ppm
Jul 27 11:33:29 bax ntpd[5857]: adjusting local clock by 0.332560s
Jul 27 11:57:09 bax ntpd[5857]: adjusting clock frequency by -0.180636 
to -15.025316ppm
Jul 27 12:16:16 bax ntpd[5857]: adjusting clock frequency by 0.153771 to 
-14.871545ppm
Jul 27 12:38:36 bax ntpd[5857]: adjusting clock frequency by -0.314905 
to -15.186450ppm
Jul 27 22:30:47 bax ntpd[5857]: adjusting clock frequency by -0.058928 
to -15.245378ppm
Jul 28 22:00:57 bax ntpd[5857]: adjusting clock frequency by 0.508728 to 
-14.750045ppm
Jul 29 07:09:05 bax ntpd[5857]: adjusting clock frequency by 0.056698 to 
-14.693347ppm
Jul 29 21:25:01 bax ntpd[5857]: adjusting clock frequency by -0.233626 
to -14.926974ppm
Jul 30 06:28:33 bax ntpd[5857]: adjusting clock frequency by -0.255362 
to -15.182336ppm
Jul 30 15:45:17 bax ntpd[5857]: adjusting clock frequency by 0.291147 to 
-14.891189ppm
Jul 31 11:57:51 bax ntpd[5857]: adjusting clock frequency by 0.198529 to 
-14.725782ppm
Aug  1 08:47:12 bax ntpd[5857]: adjusting clock frequency by -0.063213 
to -14.806622ppm
Aug  2 12:19:10 bax ntpd[5857]: adjusting clock frequency by 0.096080 to 
-14.759072ppm
Aug  3 01:30:19 bax ntpd[5857]: adjusting clock frequency by -0.353416 
to -15.112489ppm
Aug  3 08:10:34 bax ntpd[5857]: adjusting clock frequency by 0.251130 to 
-14.861359ppm
Aug  3 20:29:11 bax ntpd[5857]: adjusting clock frequency by -0.105335 
to -14.966694ppm
Aug  4 07:22:22 bax ntpd[27189]: adjusting local clock by -0.097095s
Aug  4 07:49:26 bax ntpd[27189]: adjusting clock frequency by -2.970136 
to -17.898726ppm
Aug  4 08:04:04 bax ntpd[27189]: adjusting clock frequency by 2.495076 
to -15.403651ppm