Re: random() (was Re: New GUC to sample log queries)
Peter Geoghegan <pg@bowt.ie>
From: Peter Geoghegan <pg@bowt.ie>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>,
Adrien Nayrat <adrien.nayrat@anayrat.info>, Thomas Munro <thomas.munro@enterprisedb.com>,
Dmitry Dolgov <9erthalion6@gmail.com>, Tomas Vondra <tomas.vondra@2ndquadrant.com>,
Vik Fearing <vik.fearing@2ndquadrant.com>, Robert Haas <robertmhaas@gmail.com>, Michael Paquier <michael@paquier.xyz>, David Rowley <david.rowley@2ndquadrant.com>,
Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2018-12-26T21:48:23Z
Lists: pgsql-hackers
On Wed, Dec 26, 2018 at 1:21 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: > One thing we'd have to think about if we want to take this seriously > is whether a process-wide PRNG state is really adequate; if you're > trying to make a particular call site be deterministic, you'd likely > wish it weren't interfered with by other call sites. On the flip > side, having more call sites probably makes things more random and > thus better for normal usage. Not sure how to resolve that tension > (but I don't want to build a whole lot of new infrastructure here). I don't think that you need to resolve the tension -- I'd be fine with continuing to have a process-wide PRNG that was cordoned-off for internal use. I care about making behavior deterministic when running an SQL script within a single backend. This can only be expected to work when all inputs (non-random and random alike) are carefully accounted for, including even the mutation of a seed value as the test case runs. I also found myself disabling synchronized sequential scanning within the same test case I mentioned, because they caused false positive failures very occasionally. I can imagining a similar test case where the tester has to worry about autovacuum running ANALYZE, too (as it happens, these were all INSERT ... SELECT statements, where that didn't seem to be an issue). Trying to reason about the behavior of a call site in isolation seems way too complicated to be practical. In general, there will never be a standard way to think about this kind of debugging, and it would be unreasonable to insist on providing any kind of standard framework. It's a low-level tool, useful only to backend hackers. -- Peter Geoghegan
Commits
-
Use pg_strong_random() to select each server process's random seed.
- 4203842a1cd0 12.0 landed
-
Use a separate random seed for SQL random()/setseed() functions.
- 6645ad6bdd81 12.0 landed
-
Marginal performance hacking in erand48.c.
- 6b9bba2df8d4 12.0 landed
-
Fix latent problem with pg_jrand48().
- e09046641114 12.0 landed
- f256995e33d2 10.7 landed
- d58e01f8abe2 11.2 landed
-
Silence compiler warning
- 9dc122585551 12.0 landed
-
Add log_statement_sample_rate parameter
- 88bdbd3f7460 12.0 landed