Re: Check what has been done for a uncommitted prepared transaction

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Check what has been done for a uncommitted prepared transaction
Date: 2020-05-15 06:48:08
Message-ID: cf943035f9f49415936d5df350cb671ab2f6eed9.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 2020-05-15 at 08:09 +0800, Andy Fan wrote:
> On Thu, May 14, 2020 at 9:33 PM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> wrote:
> > On Thu, 2020-05-14 at 16:26 +0800, Andy Fan wrote:
> > > Thanks, actually I don't know how to use prepared transaction and how it works.
> > > I care about this because there is a long prepared transaction exists in our customer,
> > > and we want to know what this transaction has done(like any data it changed).
> > > All the things I know is the data comes from pg_prepared_xact, but it doesn't help a lot.
> >
> > Idf you have the transaction ID from "pg_prepared_xact", you could check
> > what locks are held:
> >
> > SELECT * FROM pg_locks WHERE transactionid = ...;
> >
> > Than might give you a clue.
> >
>
> Thanks a lot. this transaction only lock a transactionid lock, so I assume there is nothing
> is done in this transaction.
>
>
> locktype | database | relation | page | tuple | virtualxid | transactionid | classid | objid | objsubid | virtualtransaction | pid | mode | granted | fastpath
> ---------------+----------+----------+------+-------+------------+---------------+---------+-------+----------+--------------------+------+---------------+---------+----------
> transactionid | | | | | | 1181845808 | | | | -1/1181845808 | | ExclusiveLock | t | f
> (1 row)

Looks like it, yes.
Roll it back then.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Suhail Bamzena 2020-05-15 07:09:20 Inherited an 18TB DB & need to backup
Previous Message Chris Withers 2020-05-15 06:06:39 Re: surprisingly slow creation of gist index used in exclude constraint