From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: When using the OSSP UUID library, cache its uuid_t state object. |
Date: | 2014-05-29 17:51:45 |
Message-ID: | E1Wq4UT-00007M-5v@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
When using the OSSP UUID library, cache its uuid_t state object.
The original coding in contrib/uuid-ossp created and destroyed a uuid_t
object (or, in some cases, even two of them) each time it was called.
This is not the intended usage: you're supposed to keep the uuid_t object
around so that the library can cache its state across uses. (Other UUID
libraries seem to keep equivalent state behind-the-scenes in static
variables, but OSSP chose differently.) Aside from being quite inefficient,
creating a new uuid_t loses knowledge of the previously generated UUID,
which in theory could result in duplicate V1-style UUIDs being created
on sufficiently fast machines.
On at least some platforms, creating a new uuid_t also draws some entropy
from /dev/urandom, leaving less for the rest of the system. This seems
sufficiently unpleasant to justify back-patching this change.
Branch
------
REL9_3_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/961dd203a2503ada9c458b79e9dbf43bb478864e
Modified Files
--------------
contrib/uuid-ossp/uuid-ossp.c | 74 ++++++++++++++++++++++++-----------------
1 file changed, 44 insertions(+), 30 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2014-05-29 19:01:51 | Re: pgsql: Reset master xmin when hot_standby_feedback disabled. |
Previous Message | Martijn van Oosterhout | 2014-05-29 16:39:50 | Re: [HACKERS] Re: pgsql: Fix bogus %name-prefix option syntax in all our Bison files. |