public inbox for [email protected]
help / color / mirror / Atom feedRe: Unique key constraint Issue
2+ messages / 2 participants
[nested] [flat]
* Re: Unique key constraint Issue
@ 2024-11-25 16:02 Tom Lane <[email protected]>
2024-11-27 02:31 ` Re: Unique key constraint Issue shashidhar Reddy <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Tom Lane @ 2024-11-25 16:02 UTC (permalink / raw)
To: shashidhar Reddy <[email protected]>; +Cc: pgsql-general
shashidhar Reddy <[email protected]> writes:
> The issue is a unique key constraint with two columns one is character
> another is integer. At some point the unique key did not work as I see
> duplicate values with these two columns combination and it happened on
> multiple servers on multiple databases on same table with same unique key.
If the table has existed for some time (like, across updates of the
underlying operating system) then your problem likely traces to
changes in the OS' sorting rules for character strings:
https://wiki.postgresql.org/wiki/Locale_data_changes
Such a change causes the unique key's index to be out of sort order
and thus effectively corrupt from PG's viewpoint: searches may or
may not find an entry that is there. Once that happens it's pretty
easy for duplicate entries to get added.
The fix is to REINDEX affected indexes. But if you already have
duplicate entries in the table, you'll need to correct them before
REINDEX will succeed.
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Unique key constraint Issue
2024-11-25 16:02 Re: Unique key constraint Issue Tom Lane <[email protected]>
@ 2024-11-27 02:31 ` shashidhar Reddy <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: shashidhar Reddy @ 2024-11-27 02:31 UTC (permalink / raw)
To: Tom Lane <[email protected]>; +Cc: pgsql-general
Thank you Tom!
The issue is with OS upgrade we could able replicate it.
On Mon, 25 Nov, 2024, 9:32 pm Tom Lane, <[email protected]> wrote:
> shashidhar Reddy <[email protected]> writes:
> > The issue is a unique key constraint with two columns one is character
> > another is integer. At some point the unique key did not work as I see
> > duplicate values with these two columns combination and it happened on
> > multiple servers on multiple databases on same table with same unique
> key.
>
> If the table has existed for some time (like, across updates of the
> underlying operating system) then your problem likely traces to
> changes in the OS' sorting rules for character strings:
>
> https://wiki.postgresql.org/wiki/Locale_data_changes
>
> Such a change causes the unique key's index to be out of sort order
> and thus effectively corrupt from PG's viewpoint: searches may or
> may not find an entry that is there. Once that happens it's pretty
> easy for duplicate entries to get added.
>
> The fix is to REINDEX affected indexes. But if you already have
> duplicate entries in the table, you'll need to correct them before
> REINDEX will succeed.
>
> regards, tom lane
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2024-11-27 02:31 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-11-25 16:02 Re: Unique key constraint Issue Tom Lane <[email protected]>
2024-11-27 02:31 ` shashidhar Reddy <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox