Re: Unique key constraint Issue

From: ajit wangkhem <ajit(dot)wangkhem(at)gmail(dot)com>
To: shashidhar Reddy <shashidharreddy001(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Unique key constraint Issue
Date: 2024-11-25 08:57:17
Message-ID: TYZPR01MB44583C36C58675B37467FA2FF12E2@TYZPR01MB4458.apcprd01.prod.exchangelabs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

If all syntax correct while creating unique key or composite unique key than there is no chances of fail. In my experience I m facing same issue but it’s rear case, if any extra space in data (insert query) than duplicate data inserted. Please chk thorough insert query . May be the issue not sure. In oracle extra space omit but in Postgres it would not.

Sent from Outlook for iOS<https://aka.ms/o0ukef>
________________________________
From: shashidhar Reddy <shashidharreddy001(at)gmail(dot)com>
Sent: Monday, November 25, 2024 2:14:37 PM
To: ajit wangkhem <ajit(dot)wangkhem(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Unique key constraint Issue

Hi Ajit,

Thank you for your reply!

The result of the query is same across all servers and yes streaming replication does not have any issue but the question is how did duplicate values entered when there unique key in place.

On Mon, 25 Nov, 2024, 1:21 pm ajit wangkhem, <ajit(dot)wangkhem(at)gmail(dot)com<mailto:ajit(dot)wangkhem(at)gmail(dot)com>> wrote:
Output should be consistent across servers below query o/p

SELECT conname, pg_get_constraintdef(oid)
FROM pg_constraint
WHERE conrelid = 'your table name'::regclass AND contype = 'u';
(different datatype combine in UK is not an issue). This issue may not happen in asynchronous, log shipping or streaming replication. In logical replication it may create problem.

On Mon, Nov 25, 2024 at 12:01 PM shashidhar Reddy <shashidharreddy001(at)gmail(dot)com<mailto:shashidharreddy001(at)gmail(dot)com>> wrote:
Hello,

We have postgresql servers with PostgreSQL 13.10 on Ubuntu release 22.04.

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. I tried db dump and restore but the key is failing to create when restore with duplicate value errors.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Mullineux 2024-11-25 08:58:15 Re: Error creating materialized view
Previous Message shashidhar Reddy 2024-11-25 08:44:37 Re: Unique key constraint Issue