Re: gen_random_uuid key collision - Mailing list pgsql-general

From Tom Lane
Subject Re: gen_random_uuid key collision
Date
Msg-id 2442920.1630626475@sss.pgh.pa.us
Whole thread Raw
In response to gen_random_uuid key collision  (jesusthefrog <jesusthefrog@gmail.com>)
Responses Re: gen_random_uuid key collision  (jesusthefrog <jesusthefrog@gmail.com>)
Re: gen_random_uuid key collision  (Peter Geoghegan <pg@bowt.ie>)
List pgsql-general
jesusthefrog <jesusthefrog@gmail.com> writes:
> I work with a postgres instance which has dozens (probably hundreds) of
> tables which each have a column defined as "uuid primary key default
> gen_random_uuid()".

> Most of the time this is fine, but one specific table has recently started
> repeatedly having inserts fail because of a unique constraint violation
> involving the primary key. The table only has ~10,000 rows, but I'll
> sometimes see two or three collisions in a single day. No other table (even
> those with many, many more rows) exhibit this issue.

That is pretty weird, all right.  The only idea that comes to mind
immediately is that maybe that table's pkey index is corrupt and needs
to be reindexed.  This isn't a great theory, because I don't see why
a corrupt index would lead to bogus unique-constraint errors rather
than missed ones.  But at least it squares with the observation that
only that table is having issues.

BTW, are you *entirely* certain that your application never inserts
non-default values into that column?

            regards, tom lane



pgsql-general by date:

Previous
From: jesusthefrog
Date:
Subject: Re: gen_random_uuid key collision
Next
From: Adrian Klaver
Date:
Subject: Re: gen_random_uuid key collision