From: | Reinhard Mayer <rumayer(at)freenet(dot)de> |
---|---|
To: | pgsql-admin(at)lists(dot)postgresql(dot)org |
Subject: | Re: Persistent changes in rolled-back transactions |
Date: | 2022-11-10 08:10:36 |
Message-ID: | b15ca389-ddc4-6036-e283-230134cdd4fb@freenet.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
On 11/10/22 02:07, Wells Oliver wrote:
> I've noticed serials still maintain incremented values even when a
> transaction is rolled back. Are there other similar persistent changes
> to be aware of?
If we relax the word "persistence" then I would mention advisory_locks:
You can request an advisory lock with pg_advisory_lock() and
pg_advisory_xact_lock().
The lock obtained by pg_advisory_lock() will survive a rollback:
postgres=# begin;
BEGIN
postgres=*# select pg_advisory_lock(1);
pg_advisory_lock
------------------
(1 row)
postgres=*# select pg_advisory_xact_lock(2);
pg_advisory_xact_lock
-----------------------
(1 row)
postgres=*# select objid from pg_locks where locktype = 'advisory';
objid
-------
2
1
(2 rows)
postgres=*# rollback ;
ROLLBACK
postgres=# select objid from pg_locks where locktype = 'advisory';
objid
-------
1
(1 rows)
==========
Reinhard
>
> --
> Wells Oliver
> wells(dot)oliver(at)gmail(dot)com <mailto:wellsoliver(at)gmail(dot)com>
From | Date | Subject | |
---|---|---|---|
Next Message | KK CHN | 2022-11-10 08:27:54 | WAL Async Replication Question |
Previous Message | Tom Lane | 2022-11-10 03:42:47 | Re: Persistent changes in rolled-back transactions |