Re: Solving the OID-collision problem - Mailing list pgsql-hackers

From Mark Woodward
Subject Re: Solving the OID-collision problem
Date
Msg-id 22923.24.91.171.78.1123154711.squirrel@mail.mohawksoft.com
Whole thread Raw
In response to Solving the OID-collision problem  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Solving the OID-collision problem  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> I was reminded again today of the problem that once a database has been
> in existence long enough for the OID counter to wrap around, people will
> get occasional errors due to OID collisions, eg
>
> http://archives.postgresql.org/pgsql-general/2005-08/msg00172.php
>
> Getting rid of OID usage in user tables doesn't really do a darn thing
> to fix this.  It may delay wrap of the OID counter, but it doesn't stop
> it; and what's more, when the problem does happen it will be more
> serious (because the OIDs assigned to persistent objects will form a
> more densely packed set, so that you have a greater chance of collisions
> over a shorter time period).
>
> We've sort of brushed this problem aside in the past by telling people
> they could just retry their transaction ... but why don't we make the
> database do the retrying?  I'm envisioning something like the attached
> quick-hack, which arranges that the pg_class and pg_type rows for tables
> will never be given OIDs duplicating an existing entry.  It basically
> just keeps generating and discarding OIDs until it finds one not in the
> table.  (This will of course not work for user-table OIDs, since we
> don't necessarily have an OID index on them, but it will work for all
> the system catalogs that have OIDs.)
>
> I seem to recall having thought of this idea before, and having rejected
> it as being too much overhead to solve a problem that occurs only rarely
> --- but in a quick test involving many repetitions of
>
>     create temp table t1(f1 int, f2 int);
>     drop table t1;
>
> the net penalty was only about a 2% slowdown on one machine, and no
> measurable difference at all on another.  So it seems like it might
> be worth doing.
>
> Comments?
>
>             regards, tom lane
>

I hope I can say this without offense, but the obvious problem is not
"collision," but "uniqueness." The most efficient way of dealing with the
issue is to remove it.

Why is there collision? It is because the number range of an OID is
currently smaller than the possible usage. Maybe it is time to rething the
OID all together and create something like a GUID (Yes, I hate them too).
I know it is ugly, but it think coming up with strategies to work around a
design limitation is a waste of time, correcting he design limitation is
the best investment.


pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: Bug introduced by recent ALTER OWNER permissions check change
Next
From: Stephen Frost
Date:
Subject: Re: US Census database (Tiger 2004FE)