Re: PKEY getting corrupted

Поиск
Список
Период
Сортировка
От Philip Semanchuk
Тема Re: PKEY getting corrupted
Дата
Msg-id F0CCA124-89F4-4829-A1FD-79B4E737AAC8@americanefficient.com
обсуждение исходный текст
Ответ на PKEY getting corrupted  ("Abraham, Danny" <danny_abraham@bmc.com>)
Список pgsql-general

> On Sep 10, 2020, at 6:43 AM, Abraham, Danny <danny_abraham@bmc.com> wrote:
>
> Hi,
>
> We have seen several times a situation where a PKEY is compromised and duplicate values are created within a table.
>
> This has happened so far on PG 928 on Linux and Windows, and also on PG955 on AIX.
>
> We ran massive test on PG10.4 but it has not recreated the problem.
>
> Has anyone faced the same issue? Any known bug?

In my experience, this is usually due to an application writing PK values rather than allowing a Postgres sequence to
generatethem, or due to the application misusing sequences. Postgres sequences are monotonically increasing, so even if
youinsert sequence values “out of order”, they won’t overlap. That’s not to say a bug in Postgres is impossible, but
everytime I’ve seen this problem, it’s been my application, not Postgres. 

Postgres 10 added new syntax for PK columns "GENERATED ALWAYS AS IDENTITY”
(https://www.postgresql.org/docs/10/sql-createtable.html).Postgres will raise an exception if an application tries to
inserta specific value into a column defined this way. When we upgraded from 9.6 to 11 we converted all of our PK
columnsto use this syntax which added a nice safety net for us.  

You’re probably already aware that 9.5.23 is the oldest supported version in the 9.x series, so the sooner you can
upgradethose unsupported 9.x versions the better. Maybe you’re in the middle of an upgrade already which is why this
cameup. :-)  

Cheers
Philip


В списке pgsql-general по дате отправления:

Предыдущее
От: Mike Martin
Дата:
Сообщение: Re: Return value of CREATE TABLE
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: PKEY getting corrupted