From: | Carlos Alves <carlos(dot)alves(at)tecnisys(dot)com(dot)br> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Question about tuple´s lock |
Date: | 2023-10-24 16:33:10 |
Message-ID: | 03df282dff2b539f8c182fb14bcc5361@tecnisys.com.br |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Em 24/10/2023 13:27, Carlos Alves escreveu:
> Hi!
>
> I need some help to understand why a transaction wiht a row delete aquire a AccessExclusiveLock and a row update a ExclusiveLock.
>
> To ilustrate, a made this scenario:
>
> create table tblock
>
> (
>
> id int primary key,
>
> value text
>
> );
>
> insert into tblock values (1, 'somevalue');
>
> First start Transaction 1:
>
> begin;
>
> update tblock set value = 'othervalue' where id = 1;
>
> -- keep this transaction opened
>
> After, start Transaction 2:
>
> begin;
>
> update tblock set value = 'onemorevalue' where id = 1;
>
> -- at this point, this transaction assumes a ExclusiveLock in the tuple;
>
> -- keep this transaction opend
>
> Then, start Transaction 3:
>
> begin;
>
> update tblock set value = 'lastofthevalues' where id = 1;
>
> -- here i can see this transaction trying to aquire a AccessExclusiveLock in this tuple
>
> So, my question is: why a delete row requires a AccessExclusiveLock in the tuple insteead of ExclusiveLock?
>
> Bellow, a image of a query over pg_locks:
>
> PostgreSQL version: 13
>
> OS: Centos 7
>
> Thanks in advance.
I typed the last command wrong. Should be:
Transaction 3:
begin;
delete from tblock where id = 1;
Sorry!
Attachment | Content-Type | Size |
---|---|---|
![]() |
image/gif | 43 bytes |
![]() |
image/gif | 3.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | pf | 2023-10-24 18:09:37 | Re: Disk wait problem... 15.4 |
Previous Message | Carlos Alves | 2023-10-24 16:27:35 | Question about tuple´s lock |