Re: pg_locks-exclusivelock for select queries

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: arun chirappurath <arunsnmimt(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: pg_locks-exclusivelock for select queries
Date: 2024-03-22 10:10:42
Message-ID: d59b4c6fc36a09f7fcf4548b0db504eedf27ce5f.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Vijaykumar Jain 2024-03-22 10:37:10 Re: uncommitted xmin 3100586 from before xid cutoff 10339367 needs to be frozen
Previous Message Laurenz Albe 2024-03-22 10:09:29 Re: uncommitted xmin 3100586 from before xid cutoff 10339367 needs to be frozen