Re: XID-assigned idle transactions affect vacuum's job.

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: XID-assigned idle transactions affect vacuum's job.
Date: 2018-03-20 11:02:31
Message-ID: CAA4eK1+8PwAMc=wO6Tucd44T+UQxTjS45YRGj9aqHV+Ujd2k-g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 20, 2018 at 12:22 PM, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
> Hi,
>
> Long transactions often annoy users because if a long transaction
> exists on a database vacuum cannot reclaim efficiently. There are
> several reason why they exist on a database but it's a common case
> where users or applications forget to commit/rollback transactions.
> That is, transaction is not executing SQL and its state is 'idle in
> transaction' on pg_stat_activity. In this case, such transactions
> don't affect vacuum's job either if they aren't assigned transaction
> id or if they don't have a snapshot. However if they have xid it will
> affect vacuum's job even if they don't have a snapshot.
>
> I think that to decide which deleted tuples must be preserved we don't
> need to care about backend PGXACT.xid but must care about PGXACT.xmin.
> But current GetOldestXmin considers both of them. I guess one reason
> why GetOldestXmin does so is that it's also used to determine where to
> truncate pg_subtrans. Is there anything else reason?
>

I think the main reason is that while computing snapshots, we also
rely on PGXACT.xid. Basically, it can be present in some other
snapshots xmin. Now, if you ignore it in vacuum (GetOldestXmin), then
it is quite possible that the xid we have ignored will be part of some
other snapshot's xmin which I think in turn can lead to wrong results.

--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2018-03-20 11:07:06 Re: [HACKERS] path toward faster partition pruning
Previous Message Asier Lostalé 2018-03-20 10:24:05 Re: BUG #15122: can't import data if table has a constraint with a function calling another function