pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feedpg_locks - what is a virtualxid locktype
3+ messages / 3 participants
[nested] [flat]
* pg_locks - what is a virtualxid locktype
@ 2019-01-29 08:57 Mariel Cherkassky <mariel.cherkassky@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Mariel Cherkassky @ 2019-01-29 08:57 UTC (permalink / raw)
To: pgsql-performance
Hey,
I noticed that pg_locks has an addition row for every transaction that is
created with a locktype "virtualxid". Tried to search it online but I didnt
find an explanation for this behavior. Does anyone can explain why it
happens ?
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pg_locks - what is a virtualxid locktype
@ 2019-01-29 09:33 Shreeyansh Dba <shreeyansh2014@gmail.com>
parent: Mariel Cherkassky <mariel.cherkassky@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Shreeyansh Dba @ 2019-01-29 09:33 UTC (permalink / raw)
To: Mariel Cherkassky <mariel.cherkassky@gmail.com>; +Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>; pgsql-performance
The virtualxid lock is special. It’s a exclusive lock on the transaction’s
own virtual transaction ID that every transaction always holds. No other
transaction can ever acquire it while the transaction is running.
The purpose of this is to allow one transaction to wait until another
transaction commits or rolls back using PostgreSQL’s locking mechanism, and
it’s used internally.
Thanks & Regards,
*Shreeyansh DBA Team*
www.shreeyansh.com
On Tue, Jan 29, 2019 at 2:27 PM Mariel Cherkassky <
mariel.cherkassky@gmail.com> wrote:
> Hey,
> I noticed that pg_locks has an addition row for every transaction that is
> created with a locktype "virtualxid". Tried to search it online but I didnt
> find an explanation for this behavior. Does anyone can explain why it
> happens ?
>
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pg_locks - what is a virtualxid locktype
@ 2019-01-29 15:12 Alvaro Herrera <alvherre@2ndquadrant.com>
parent: Shreeyansh Dba <shreeyansh2014@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Alvaro Herrera @ 2019-01-29 15:12 UTC (permalink / raw)
To: Shreeyansh Dba <shreeyansh2014@gmail.com>; +Cc: Mariel Cherkassky <mariel.cherkassky@gmail.com>; Pgsql-admin <pgsql-admin@lists.postgresql.org>; pgsql-performance
On 2019-Jan-29, Shreeyansh Dba wrote:
> The virtualxid lock is special. It’s a exclusive lock on the transaction’s
> own virtual transaction ID that every transaction always holds. No other
> transaction can ever acquire it while the transaction is running.
> The purpose of this is to allow one transaction to wait until another
> transaction commits or rolls back using PostgreSQL’s locking mechanism, and
> it’s used internally.
A little more specific than that: it's used when some process (such as
CREATE INDEX CONCURRENTLY) needs to wait even on sessions that might be
read-only. Such transactions don't have transaction-ids that write
transactions have, which is why the only way is to wait on the virtual
transaction-id.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2019-01-29 15:12 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-01-29 08:57 pg_locks - what is a virtualxid locktype Mariel Cherkassky <mariel.cherkassky@gmail.com>
2019-01-29 09:33 ` Shreeyansh Dba <shreeyansh2014@gmail.com>
2019-01-29 15:12 ` Alvaro Herrera <alvherre@2ndquadrant.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox