pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #14838: clock_timestamp() returns same values for each row
5+ messages / 5 participants
[nested] [flat]

* BUG #14838: clock_timestamp() returns same values for each row
@ 2017-09-29 13:43 zam6ak@gmail.com
  2017-09-29 17:45 ` Re: BUG #14838: clock_timestamp() returns same values for each row Jeff Janes <jeff.janes@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: zam6ak@gmail.com @ 2017-09-29 13:43 UTC (permalink / raw)
  To: pgsql-bugs; +Cc: zam6ak@gmail.com

The following bug has been logged on the website:

Bug reference:      14838
Logged by:          zam zam
Email address:      zam6ak@gmail.com
PostgreSQL version: 10rc1
Operating system:   Windows 10
Description:        

Hello

We use clock_timestamp() function in our code and I have noticed that in PG
10 RC1 it returns same values across rows...

Here is the output from 9.6 compare to 10rc1

select version();
-- "PostgreSQL 9.6.3, compiled by Visual C++ build 1800, 64-bit"

select clock_timestamp() from generate_series(1,10)
-- "clock_timestamp"
-- "2017-09-29 09:39:34.820954-04"
-- "2017-09-29 09:39:34.820977-04"
-- "2017-09-29 09:39:34.820979-04"
-- "2017-09-29 09:39:34.820981-04"
-- "2017-09-29 09:39:34.820982-04"
-- "2017-09-29 09:39:34.820983-04"
-- "2017-09-29 09:39:34.820984-04"
-- "2017-09-29 09:39:34.820986-04"
-- "2017-09-29 09:39:34.820987-04"
-- "2017-09-29 09:39:34.820988-04"



select version();
-- "PostgreSQL 10rc1 on x86_64-pc-mingw64, compiled by gcc.exe (Rev5, Built
by MSYS2 project) 4.9.2, 64-bit"

select clock_timestamp() from generate_series(1,10)
-- "clock_timestamp"
-- "2017-09-29 09:38:45.779869-04"
-- "2017-09-29 09:38:45.779869-04"
-- "2017-09-29 09:38:45.779869-04"
-- "2017-09-29 09:38:45.779869-04"
-- "2017-09-29 09:38:45.779869-04"
-- "2017-09-29 09:38:45.779869-04"
-- "2017-09-29 09:38:45.779869-04"
-- "2017-09-29 09:38:45.779869-04"
-- "2017-09-29 09:38:45.779869-04"
-- "2017-09-29 09:38:45.779869-04"






-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #14838: clock_timestamp() returns same values for each row
  2017-09-29 13:43 BUG #14838: clock_timestamp() returns same values for each row zam6ak@gmail.com
@ 2017-09-29 17:45 ` Jeff Janes <jeff.janes@gmail.com>
  2017-09-29 18:03   ` Re: BUG #14838: clock_timestamp() returns same values for each row Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: Jeff Janes @ 2017-09-29 17:45 UTC (permalink / raw)
  To: zam6ak@gmail.com; +Cc: pgsql-bugs

On Fri, Sep 29, 2017 at 6:43 AM, <zam6ak@gmail.com> wrote:

> The following bug has been logged on the website:
>
> Bug reference:      14838
> Logged by:          zam zam
> Email address:      zam6ak@gmail.com
> PostgreSQL version: 10rc1
> Operating system:   Windows 10
> Description:
>
> Hello
>
> We use clock_timestamp() function in our code and I have noticed that in PG
> 10 RC1 it returns same values across rows...
>
> Here is the output from 9.6 compare to 10rc1
>
> select version();
> -- "PostgreSQL 9.6.3, compiled by Visual C++ build 1800, 64-bit"
>
> -- "PostgreSQL 10rc1 on x86_64-pc-mingw64, compiled by gcc.exe (Rev5, Built
> by MSYS2 project) 4.9.2, 64-bit"
>
>
Probably not an issue of the different versions, but rather different
compilers (or maybe different hardware?).

I get the same behavior on these two versions:

PostgreSQL 9.6.5, compiled by Visual C++ build 1800, 64-bit
PostgreSQL 10rc1, compiled by Visual C++ build 1800, 64-bit

and that behavior is that the timestamp jumps 500 usec at a time, despite
looking as if it might have usec granularity:



 2017-09-29 10:34:50.881312-07
 2017-09-29 10:34:50.881312-07
 2017-09-29 10:34:50.881312-07
 2017-09-29 10:34:50.881312-07
 2017-09-29 10:34:50.881312-07
 2017-09-29 10:34:50.881812-07  <-- see here and above
 2017-09-29 10:34:50.881812-07
 2017-09-29 10:34:50.881812-07
 2017-09-29 10:34:50.881812-07

You probably don't see the jump in your 2nd example because you didn't run
enough rows to cross a 500 usec boundary.

Cheers,

Jeff

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #14838: clock_timestamp() returns same values for each row
  2017-09-29 13:43 BUG #14838: clock_timestamp() returns same values for each row zam6ak@gmail.com
  2017-09-29 17:45 ` Re: BUG #14838: clock_timestamp() returns same values for each row Jeff Janes <jeff.janes@gmail.com>
@ 2017-09-29 18:03   ` Tom Lane <tgl@sss.pgh.pa.us>
  2017-09-29 22:41     ` Re: BUG #14838: clock_timestamp() returns same values for each row zambak zambak <zam6ak@gmail.com>
  2017-09-29 22:54     ` Re: BUG #14838: clock_timestamp() returns same values for each row Magnus Hagander <magnus@hagander.net>
  0 siblings, 2 replies; 5+ messages in thread

From: Tom Lane @ 2017-09-29 18:03 UTC (permalink / raw)
  To: Jeff Janes <jeff.janes@gmail.com>; +Cc: pgsql-bugs

Jeff Janes <jeff.janes@gmail.com> writes:
> On Fri, Sep 29, 2017 at 6:43 AM, <zam6ak@gmail.com> wrote:
>> We use clock_timestamp() function in our code and I have noticed that in PG
>> 10 RC1 it returns same values across rows...

> Probably not an issue of the different versions, but rather different
> compilers (or maybe different hardware?).

AFAICS, our code in this area (see src/port/gettimeofday.c) has not
changed since 9.5.  I'm suspicious of a platform change.

> I get the same behavior on these two versions:
> ...
> and that behavior is that the timestamp jumps 500 usec at a time, despite
> looking as if it might have usec granularity:

What gettimeofday.c does is to use GetSystemTimePreciseAsFileTime()
if it can get hold of that, otherwise fall back to
GetSystemTimeAsFileTime().  I don't see anything very specific in
Windows' documentation about the resolution to be expected from either
one, but I wonder if the OP's 9.6 installation is using the former
while for some reason his 10rc1 installation is using the latter.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #14838: clock_timestamp() returns same values for each row
  2017-09-29 13:43 BUG #14838: clock_timestamp() returns same values for each row zam6ak@gmail.com
  2017-09-29 17:45 ` Re: BUG #14838: clock_timestamp() returns same values for each row Jeff Janes <jeff.janes@gmail.com>
  2017-09-29 18:03   ` Re: BUG #14838: clock_timestamp() returns same values for each row Tom Lane <tgl@sss.pgh.pa.us>
@ 2017-09-29 22:41     ` zambak zambak <zam6ak@gmail.com>
  1 sibling, 0 replies; 5+ messages in thread

From: zambak zambak @ 2017-09-29 22:41 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Jeff Janes <jeff.janes@gmail.com>; pgsql-bugs

On Fri, Sep 29, 2017 at 2:03 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Jeff Janes <jeff.janes@gmail.com> writes:
> > On Fri, Sep 29, 2017 at 6:43 AM, <zam6ak@gmail.com> wrote:
> >> We use clock_timestamp() function in our code and I have noticed that
> in PG
> >> 10 RC1 it returns same values across rows...
>
> > Probably not an issue of the different versions, but rather different
> > compilers (or maybe different hardware?).
>
> AFAICS, our code in this area (see src/port/gettimeofday.c) has not
> changed since 9.5.  I'm suspicious of a platform change.
>
> > I get the same behavior on these two versions:
> > ...
> > and that behavior is that the timestamp jumps 500 usec at a time, despite
> > looking as if it might have usec granularity:
>
> What gettimeofday.c does is to use GetSystemTimePreciseAsFileTime()
> if it can get hold of that, otherwise fall back to
> GetSystemTimeAsFileTime().  I don't see anything very specific in
> Windows' documentation about the resolution to be expected from either
> one, but I wonder if the OP's 9.6 installation is using the former
> while for some reason his 10rc1 installation is using the latter.
>


Just for the record, both PG instances I tested this on are running on the
same OS system in same VM, just different ports.
I also tried Windows Server 2012 (in VM) and am getting same issue.



>
>                         regards, tom lane
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #14838: clock_timestamp() returns same values for each row
  2017-09-29 13:43 BUG #14838: clock_timestamp() returns same values for each row zam6ak@gmail.com
  2017-09-29 17:45 ` Re: BUG #14838: clock_timestamp() returns same values for each row Jeff Janes <jeff.janes@gmail.com>
  2017-09-29 18:03   ` Re: BUG #14838: clock_timestamp() returns same values for each row Tom Lane <tgl@sss.pgh.pa.us>
@ 2017-09-29 22:54     ` Magnus Hagander <magnus@hagander.net>
  1 sibling, 0 replies; 5+ messages in thread

From: Magnus Hagander @ 2017-09-29 22:54 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Jeff Janes <jeff.janes@gmail.com>; pgsql-bugs

On Fri, Sep 29, 2017 at 8:03 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Jeff Janes <jeff.janes@gmail.com> writes:
> > On Fri, Sep 29, 2017 at 6:43 AM, <zam6ak@gmail.com> wrote:
> >> We use clock_timestamp() function in our code and I have noticed that
> in PG
> >> 10 RC1 it returns same values across rows...
>
> > Probably not an issue of the different versions, but rather different
> > compilers (or maybe different hardware?).
>
> AFAICS, our code in this area (see src/port/gettimeofday.c) has not
> changed since 9.5.  I'm suspicious of a platform change.
>
> > I get the same behavior on these two versions:
> > ...
> > and that behavior is that the timestamp jumps 500 usec at a time, despite
> > looking as if it might have usec granularity:
>
> What gettimeofday.c does is to use GetSystemTimePreciseAsFileTime()
> if it can get hold of that, otherwise fall back to
> GetSystemTimeAsFileTime().  I don't see anything very specific in
> Windows' documentation about the resolution to be expected from either
> one, but I wonder if the OP's 9.6 installation is using the former
> while for some reason his 10rc1 installation is using the latter.
>

The documentatino for  GetSystemTimePreciseAsFileTime() specifically says "the
current system date and time with the highest possible level of precision
(<1us)". Which is not super specific, but certainly a lot lower than the
500us observed.

GetSystemTime() is AFAIK at millisecond level, I recall reading about 10ms.

-- 
 Magnus Hagander
 Me: https://www.hagander.net/ <http://www.hagander.net/;
 Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/;

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2017-09-29 22:54 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-09-29 13:43 BUG #14838: clock_timestamp() returns same values for each row zam6ak@gmail.com
2017-09-29 17:45 ` Jeff Janes <jeff.janes@gmail.com>
2017-09-29 18:03   ` Tom Lane <tgl@sss.pgh.pa.us>
2017-09-29 22:41     ` zambak zambak <zam6ak@gmail.com>
2017-09-29 22:54     ` Magnus Hagander <magnus@hagander.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox