Re: clock sync - Mailing list pgsql-hackers

From cbbrowne@cbbrowne.com
Subject Re: clock sync
Date
Msg-id 20030109155126.9A1894BEA3@cbbrowne.com
Whole thread Raw
In response to clock sync  ("John Liu" <johnl@synthesys.com>)
List pgsql-hackers
On Thu, 09 Jan 2003 08:39:33 CST, the world broke into rejoicing as
"John Liu" <johnl@synthesys.com>  said:
> How do I know the clock on the machine you're
> running on will be set to the same time as the 
> clock on the database? how postgre handle this
> internal?

You'll know because you already run NTP on all your servers to make
sure that they are synchronizing times, right?

PostgreSQL doesn't include time synchronization software because NTP
does that perfectly well, just as it doesn't include a job scheduler
because cron does that perfectly well.

... And if your machines have substantially different times, different
sorts of issues will emerge depending on what you're doing.

- If the "client" sends over literal current time stamps based on what
time it thinks it is, that may differ from what time the server thinks
it is.

- If you do that, and then try looking in PostgreSQL logs, based on
the "client's" timestamps, you'll look at the wrong times, and get
confused.

- If the client passes in things that select now(), timestamps will be
returned based on when the /server/ thinks it is.  Which should leave
the database consistent, but which might confuse the client if it has
logic that processes that time, and gets deranged because now()
differs massively from what time it thinks it is.

The case where you'll get /badly/ bitten is if you're trying to do
replication with servers that have substantially differing ideas as to
what time it is.

But what you /should/ do is run NTP on all your machines, thus getting
rid of the problem.  <http://www.ntp.org/>
--
If this was helpful, <http://svcs.affero.net/rm.php?r=cbbrowne> rate me
http://www3.sympatico.ca/cbbrowne/ntp.html
Rules  of the  Evil  Overlord #30.   "All  bumbling conjurers,  clumsy
squires, no-talent  bards, and  cowardly thieves in  the land  will be
preemptively put  to death.  My foes  will surely give  up and abandon
their quest if they have no source of comic relief."
<http://www.eviloverlord.com/>


pgsql-hackers by date:

Previous
From: Peter Mount
Date:
Subject: Re: psql and readline
Next
From: Rod Taylor
Date:
Subject: Re: psql and readline