pgsql: Initialize random() in bootstrap/stand-alone postgres and in ini

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Initialize random() in bootstrap/stand-alone postgres and in ini
Date: 2018-09-24 06:04:56
Message-ID: E1g4JzM-0001vt-DH@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Initialize random() in bootstrap/stand-alone postgres and in initdb.

This removes a difference between the standard IsUnderPostmaster
execution environment and that of --boot and --single. In a stand-alone
backend, "SELECT random()" always started at the same seed.

On a system capable of using posix shared memory, initdb could still
conclude "selecting dynamic shared memory implementation ... sysv".
Crashed --boot or --single postgres processes orphaned shared memory
objects having names that collided with the not-actually-random names
that initdb probed. The sysv fallback appeared after ten crashes of
--boot or --single postgres. Since --boot and --single are rare in
production use, systems used for PostgreSQL development are the
principal candidate to notice this symptom.

Back-patch to 9.3 (all supported versions). PostgreSQL 9.4 introduced
dynamic shared memory, but 9.3 does share the "SELECT random()" problem.

Reviewed by Tom Lane and Kyotaro HORIGUCHI.

Discussion: https://postgr.es/m/20180915221546.GA3159382@rfd.leadboat.com

Branch
------
REL9_4_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/401228183a63254a8edbded3693124ad466b185b

Modified Files
--------------
src/backend/bootstrap/bootstrap.c | 8 ++++++++
src/backend/tcop/postgres.c | 8 ++++++++
src/bin/initdb/initdb.c | 3 +++
3 files changed, 19 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Joe Conway 2018-09-24 14:15:32 pgsql: Document aclitem functions and operators
Previous Message Tom Lane 2018-09-23 22:34:25 pgsql: Doc: warn against using parallel restore with --load-via-partiti