diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-01-24 11:31:54 -0500 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-01-24 11:31:54 -0500 |
| commit | e6c3ba7fbfd59ceabcf9bdaf52d71b44831b09d2 (patch) | |
| tree | 20b9ed2e577c6908b2cd4830be04323bb49108e2 /src/bin/pgbench/t/001_pgbench_with_server.pl | |
| parent | 19184fcc09739abf75ccdada965ed6135c6d07c3 (diff) | |
| download | postgresql-e6c3ba7fbfd59ceabcf9bdaf52d71b44831b09d2.tar.gz | |
Fix portability problem in pgbench.
The pgbench regression test supposed that srandom() with a specific value
would result in deterministic output from random(), as required by POSIX.
It emerges however that OpenBSD is too smart to be constrained by mere
standards, so their random() emits nondeterministic output anyway.
While a workaround does exist, what seems like a better fix is to stop
relying on the platform's srandom()/random() altogether, so that what
you get from --random-seed=N is not merely deterministic but platform
independent. Hence, use a separate pg_jrand48() random sequence in
place of random().
Also adjust the regression test case that's supposed to detect
nondeterminism so that it's more likely to detect it; the original
choice of random_zipfian parameter tended to produce the same output
all the time even if the underlying behavior wasn't deterministic.
In passing, improve pgbench's docs about random_zipfian().
Back-patch to v11 where this code was introduced.
Fabien Coelho and Tom Lane
Discussion: https://postgr.es/m/4615.1547792324@sss.pgh.pa.us
Diffstat (limited to 'src/bin/pgbench/t/001_pgbench_with_server.pl')
| -rw-r--r-- | src/bin/pgbench/t/001_pgbench_with_server.pl | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/bin/pgbench/t/001_pgbench_with_server.pl b/src/bin/pgbench/t/001_pgbench_with_server.pl index c87748086a..ad15ba66ea 100644 --- a/src/bin/pgbench/t/001_pgbench_with_server.pl +++ b/src/bin/pgbench/t/001_pgbench_with_server.pl @@ -259,11 +259,11 @@ pgbench( [ qr{setting random seed to 5432\b}, - # After explicit seeding, the four * random checks (1-3,20) should be - # deterministic, but not necessarily portable. - qr{command=1.: int 1\d\b}, # uniform random: 12 on linux - qr{command=2.: int 1\d\d\b}, # exponential random: 106 on linux - qr{command=3.: int 1\d\d\d\b}, # gaussian random: 1462 on linux + # After explicit seeding, the four random checks (1-3,20) are + # deterministic + qr{command=1.: int 13\b}, # uniform random + qr{command=2.: int 116\b}, # exponential random + qr{command=3.: int 1498\b}, # gaussian random qr{command=4.: int 4\b}, qr{command=5.: int 5\b}, qr{command=6.: int 6\b}, @@ -276,7 +276,7 @@ pgbench( qr{command=15.: double 15\b}, qr{command=16.: double 16\b}, qr{command=17.: double 17\b}, - qr{command=20.: int \d\b}, # zipfian random: 1 on linux + qr{command=20.: int 1\b}, # zipfian random qr{command=21.: double -27\b}, qr{command=22.: double 1024\b}, qr{command=23.: double 1\b}, @@ -471,7 +471,7 @@ for my $i (1, 2) \set ur random(1000, 1999) \set er random_exponential(2000, 2999, 2.0) \set gr random_gaussian(3000, 3999, 3.0) -\set zr random_zipfian(4000, 4999, 2.5) +\set zr random_zipfian(4000, 4999, 1.5) INSERT INTO seeded_random(seed, rand, val) VALUES (:random_seed, 'uniform', :ur), (:random_seed, 'exponential', :er), |
