pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: arun chirappurath <arunsnmimt@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: pg_locks-exclusivelock for select queries
Date: Fri, 22 Mar 2024 11:10:42 +0100
Message-ID: <d59b4c6fc36a09f7fcf4548b0db504eedf27ce5f.camel@cybertec.at> (raw)
In-Reply-To: <CAA23Sdt_abrMxJnZbJj5-rr5Z5C1J_UXUnORnbuCg8x3TZ6JoA@mail.gmail.com>
References: <CAA23Sdt_abrMxJnZbJj5-rr5Z5C1J_UXUnORnbuCg8x3TZ6JoA@mail.gmail.com>

On Fri, 2024-03-22 at 12:43 +0530, arun chirappurath wrote:
> I am running below query on a database. why is it creating a exclusive lock on a virtualxid?
> I am running some SELECT queries and its creating an ExclusiveLock in virtualxid? is this normal?
> 
> SELECT datname, pid, state, query, age(clock_timestamp(), query_start) AS age 
> FROM pg_stat_activity
> WHERE state <> 'idle' 
>     --AND query NOT LIKE '% FROM pg_stat_activity %' 
> ORDER BY age;
> 
> |locktype  |database|relation|page|tuple|virtualxid|transactionid|classid|objid|objsubid|virtualtransaction|pid   |mode           |granted|fastpath|waitstart|
> |----------|--------|--------|----|-----|----------|-------------|-------|-----|--------|------------------|------|---------------|-------|--------|---------|
> |relation  |58,007  |12,073  |    |     |          |             |       |     |        |5/165             |21,912|AccessShareLock|true   |true    |         |
> |virtualxid|        |        |    |     |5/165     |             |       |     |        |5/165             |21,912|ExclusiveLock  |true   |true    |         |

That's normal.  Every transaction has an exclusive lock on its own transaction ID.

Yours,
Laurenz Albe


view thread (3+ messages)  latest in thread

Message-ID: <d59b4c6fc36a09f7fcf4548b0db504eedf27ce5f.camel@cybertec.at>
Permalink:  ../d59b4c6fc36a09f7fcf4548b0db504eedf27ce5f.camel@cybertec.at/
Also on:    postgresql.org/message-id/d59b4c6fc36a09f7fcf4548b0db504eedf27ce5f.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: laurenz.albe@cybertec.at, arunsnmimt@gmail.com
  Subject: Re: pg_locks-exclusivelock for select queries
  In-Reply-To: <d59b4c6fc36a09f7fcf4548b0db504eedf27ce5f.camel@cybertec.at>
  References: <CAA23Sdt_abrMxJnZbJj5-rr5Z5C1J_UXUnORnbuCg8x3TZ6JoA@mail.gmail.com> <d59b4c6fc36a09f7fcf4548b0db504eedf27ce5f.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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