Re: clock sync

From: cbbrowne(at)cbbrowne(dot)com
To: "Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clock sync
Date: 2003-01-09 15:51:26
Message-ID: 20030109155126.9A1894BEA3@cbbrowne.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 09 Jan 2003 08:39:33 CST, the world broke into rejoicing as
"John Liu" <johnl(at)synthesys(dot)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/>

Browse pgsql-hackers by date

  From Date Subject
Next Message Rod Taylor 2003-01-09 15:56:56 Re: psql and readline
Previous Message Peter Mount 2003-01-09 15:42:15 Re: psql and readline