Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Hackers > Execution-time-...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 7 Topic 9403 of 10966
Post > Topic >>

Execution-time-sensitive timestamp regression tests

by tgl@[EMAIL PROTECTED] (Tom Lane) May 23, 2008 at 03:53 PM

I've been puzzled by a couple of recent buildfarm failures:
http://www.pgbuildfarm.org/cgi-bin/show_log.pl?nm=dawn_bat&dt=2008-05-22%2006:00:01
http://www.pgbuildfarm.org/cgi-bin/show_log.pl?nm=vaquita&dt=2008-05-19%2020:00:03

Both fail the timestamp test like this:

*** ./expected/timestamp.out	Mon May 19 21:01:31 2008
--- ./results/timestamp.out	Mon May 19 21:34:23 2008
***************
*** 36,42 ****
  SELECT count(*) AS None FROM TIMESTAMP_TBL WHERE d1 = timestamp without
time zone 'now';
   none 
  ------
!     0
  (1 row)
  
  DELETE FROM TIMESTAMP_TBL;
--- 36,42 ----
  SELECT count(*) AS None FROM TIMESTAMP_TBL WHERE d1 = timestamp without
time zone 'now';
   none 
  ------
!     1
  (1 row)
  
  DELETE FROM TIMESTAMP_TBL;

which seemed a bit baffling until I looked into the test source:

CREATE TABLE TIMESTAMP_TBL ( d1 timestamp(2) without time zone);
INSERT INTO TIMESTAMP_TBL VALUES ('now');
-- six more inserts and three selects
SELECT count(*) AS None FROM TIMESTAMP_TBL WHERE d1 = timestamp without
time zone 'now';
 none 
------
    0
(1 row)

IOW, this test is assuming that the value of now() must change in the
time it takes to execute a few SQL statements.  The buildfarm re****ts
indicate that it didn't change.

Both of the observed failures are on Windows machines, where I'm told
that the resolution of gettimeofday() is an abysmal 55msec, so it seems
that the only surprise here is that we haven't seen the failure often
before.

It might be worth trying to improve the resolution of now() on Windows,
though I didn't much care for the ideas Magnus had about how to do that
when I asked him earlier today.

In any case I think this regression test is broken-by-design (and so is
the very similar code in the timestamptz test).  Aside from the risk
we see here, there are previously-recognized race conditions in the
statements I omitted: if local midnight p***** during the sequence of
statements, you get a failure.

What I'm considering doing is putting a BEGIN/COMMIT around the whole
sequence, which will guarantee that now() does *not* advance, thus
eliminating the midnight gotcha.  This would mean that the expected
output of the comparison to 'now' changes from 0 rows to 1 row.

Objections, better ideas?

			regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
 




 7 Posts in Topic:
Execution-time-sensitive timestamp regression tests
tgl@[EMAIL PROTECTED] (T  2008-05-23 15:53:49 
Re: Execution-time-sensitive timestamp regression tests
magnus@[EMAIL PROTECTED]   2008-05-23 16:29:22 
Re: Execution-time-sensitive timestamp regression tests
tgl@[EMAIL PROTECTED] (T  2008-05-23 17:03:53 
Re: Execution-time-sensitive timestamp regression tests
andrew@[EMAIL PROTECTED]   2008-05-23 18:47:29 
Re: Execution-time-sensitive timestamp regression tests
Rainer Bauer <usenet@[  2008-05-25 00:01:10 
Re: Execution-time-sensitive timestamp regression tests
stark@[EMAIL PROTECTED]   2008-05-23 16:36:19 
Re: Execution-time-sensitive timestamp regression tests
tgl@[EMAIL PROTECTED] (T  2008-05-24 23:34:05 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 12:07:19 CST 2008.