Thread: now() time off

now() time off

From
John McCawley
Date:
Earlier this week when I logged into my database, I just so happened to
notice that the value for now() was six hours off of the time reported
by the operating system when using the date command from the command
line.  How is this possible?  I rebooted the server and the problem
magically went away.  I am quite certain that I didn't modify anything
in the database that should cause this problem.  It turns out that that
the now() time has been off for some time, and resulted in quite a bit
of corrupted data.  What exactly should I do in the future to keep this
from happening, or where should I look for clues?

John

Re: now() time off

From
Scott Marlowe
Date:
On Wed, 2006-02-22 at 16:36, John McCawley wrote:
> Earlier this week when I logged into my database, I just so happened to
> notice that the value for now() was six hours off of the time reported
> by the operating system when using the date command from the command
> line.  How is this possible?  I rebooted the server and the problem
> magically went away.  I am quite certain that I didn't modify anything
> in the database that should cause this problem.  It turns out that that
> the now() time has been off for some time, and resulted in quite a bit
> of corrupted data.  What exactly should I do in the future to keep this
> from happening, or where should I look for clues?

Sounds like a time zone issue.  I'd start looking there.

Re: now() time off

From
"Jim C. Nasby"
Date:
On Wed, Feb 22, 2006 at 04:46:35PM -0600, Scott Marlowe wrote:
> On Wed, 2006-02-22 at 16:36, John McCawley wrote:
> > Earlier this week when I logged into my database, I just so happened to
> > notice that the value for now() was six hours off of the time reported
> > by the operating system when using the date command from the command
> > line.  How is this possible?  I rebooted the server and the problem
> > magically went away.  I am quite certain that I didn't modify anything
> > in the database that should cause this problem.  It turns out that that
> > the now() time has been off for some time, and resulted in quite a bit
> > of corrupted data.  What exactly should I do in the future to keep this
> > from happening, or where should I look for clues?
>
> Sounds like a time zone issue.  I'd start looking there.

I've been bitten by this before as well. I'd be in favor of adding an
option such that postmaster would refuse to start if TZ was something
other than UTC; I'd much rather that then have a bunch of data get
screwed up...
--
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461

Re: now() time off

From
Martijn van Oosterhout
Date:
On Wed, Feb 22, 2006 at 06:35:55PM -0600, Jim C. Nasby wrote:
> On Wed, Feb 22, 2006 at 04:46:35PM -0600, Scott Marlowe wrote:
> > Sounds like a time zone issue.  I'd start looking there.
>
> I've been bitten by this before as well. I'd be in favor of adding an
> option such that postmaster would refuse to start if TZ was something
> other than UTC; I'd much rather that then have a bunch of data get
> screwed up...

Alternativly you could just set the "timezone" parameter in the
postgresql configuration...

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Attachment

Re: now() time off

From
"Jim C. Nasby"
Date:
On Thu, Feb 23, 2006 at 12:41:38PM +0100, Martijn van Oosterhout wrote:
> On Wed, Feb 22, 2006 at 06:35:55PM -0600, Jim C. Nasby wrote:
> > On Wed, Feb 22, 2006 at 04:46:35PM -0600, Scott Marlowe wrote:
> > > Sounds like a time zone issue.  I'd start looking there.
> >
> > I've been bitten by this before as well. I'd be in favor of adding an
> > option such that postmaster would refuse to start if TZ was something
> > other than UTC; I'd much rather that then have a bunch of data get
> > screwed up...
>
> Alternativly you could just set the "timezone" parameter in the
> postgresql configuration...

Wow, didn't know that was there... was it added fairly recently or have
I just been blind?
--
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461

Re: now() time off

From
Michael Fuhr
Date:
On Thu, Feb 23, 2006 at 04:21:19PM -0600, Jim C. Nasby wrote:
> On Thu, Feb 23, 2006 at 12:41:38PM +0100, Martijn van Oosterhout wrote:
> > Alternativly you could just set the "timezone" parameter in the
> > postgresql configuration...
>
> Wow, didn't know that was there... was it added fairly recently or have
> I just been blind?

http://www.postgresql.org/docs/7.3/interactive/release-7-3.html

"Add configuration variables datestyle and timezone (Tom)"

--
Michael Fuhr

Re: now() time off

From
"Jim C. Nasby"
Date:
On Thu, Feb 23, 2006 at 03:49:50PM -0700, Michael Fuhr wrote:
> On Thu, Feb 23, 2006 at 04:21:19PM -0600, Jim C. Nasby wrote:
> > On Thu, Feb 23, 2006 at 12:41:38PM +0100, Martijn van Oosterhout wrote:
> > > Alternativly you could just set the "timezone" parameter in the
> > > postgresql configuration...
> >
> > Wow, didn't know that was there... was it added fairly recently or have
> > I just been blind?
>
> http://www.postgresql.org/docs/7.3/interactive/release-7-3.html
>
> "Add configuration variables datestyle and timezone (Tom)"

Whew. I started on 7.2, so I have a bit of an excuse. :)
--
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461