pgsql: Improve generation algorithm for database system identifier.

Started by Tom Laneabout 12 years ago3 messagescomitters
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

Improve generation algorithm for database system identifier.

As noted some time ago, the original coding had a typo ("|" for "^")
that made the result less unique than intended. Even the intended
behavior is obsolete since it was based on wanting to produce a
usable value even if we didn't have int64 arithmetic --- a limitation
we stopped supporting years ago. Instead, let's redefine the system
identifier as tv_sec in the upper 32 bits (same as before), tv_usec
in the next 20 bits, and the low 12 bits of getpid() in the remaining
bits. This is still hardly guaranteed-universally-unique, but it's
noticeably better than before. Per my proposal at
<29019.1374535940@sss.pgh.pa.us>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/5035701e07e8bd395aa878465a102afd7b74e8c3

Modified Files
--------------
src/backend/access/transam/xlog.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

#2Andres Freund
andres@anarazel.de
In reply to: Tom Lane (#1)
Re: pgsql: Improve generation algorithm for database system identifier.

Hi Tom,

On 2014-04-26 19:11:14 +0000, Tom Lane wrote:

Improve generation algorithm for database system identifier.

As noted some time ago, the original coding had a typo ("|" for "^")
that made the result less unique than intended. Even the intended
behavior is obsolete since it was based on wanting to produce a
usable value even if we didn't have int64 arithmetic --- a limitation
we stopped supporting years ago. Instead, let's redefine the system
identifier as tv_sec in the upper 32 bits (same as before), tv_usec
in the next 20 bits, and the low 12 bits of getpid() in the remaining
bits. This is still hardly guaranteed-universally-unique, but it's
noticeably better than before. Per my proposal at
<29019.1374535940@sss.pgh.pa.us>

Modified Files
--------------
src/backend/access/transam/xlog.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

I just noticed that pg_resetxlog.c has a copy of the identifer
generation algorithm that's not been adjusted by that commit.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andres Freund (#2)
Re: pgsql: Improve generation algorithm for database system identifier.

Andres Freund <andres@2ndquadrant.com> writes:

I just noticed that pg_resetxlog.c has a copy of the identifer
generation algorithm that's not been adjusted by that commit.

Oh, I'd forgotten about that :-(. Thanks, will fix.

regards, tom lane

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers