Saw some strange behavior when using `INSERT ON CONFLICT` inside a transaction.

From: Sagar Tiwari <iaansagar(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Saw some strange behavior when using `INSERT ON CONFLICT` inside a transaction.
Date: 2025-08-30 07:43:35
Message-ID: CAJ8WsYMYH0ZbxA4krA0JNnF1fPdvtdANxV-WDbwZCcC++QUODw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

Repro steps:
* I created the table:
```
create table t (col TEXT primary key);
```

* Open two database consoles and use the following queries in them:

```
1 begin;
2 select txid_current();
3 insert into t (col) values ('test') on conflict (col) do nothing;
4 commit;
```

I ran 1 and 2 in both. It worked for both.
And then I ran query 3 in the first console. It worked.
After that I ran query 3 in the second console. It got stuck!
When I commit the tx in first console, the stuck query in second console
finishes
The transaction isolation level is 'read committed'.

--
Best Regards
Sagar Tiwari

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Achilleas Mantzios 2025-08-30 10:43:23 Re: Saw some strange behavior when using `INSERT ON CONFLICT` inside a transaction.
Previous Message Ron Johnson 2025-08-28 05:31:41 Re: psql --html and to_char()