From: | Pantelis Theodosiou <ypercube(at)gmail(dot)com> |
---|---|
To: | Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> |
Cc: | Nikita Malakhov <hukutoc(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Tuples inserted and deleted by the same transaction |
Date: | 2022-09-13 10:40:14 |
Message-ID: | CAE3TBxzna0UeEqjkxZoGGCF3Y7MRiuNqTdEu7aVOrY7vEUmGUA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Sep 13, 2022 at 11:04 AM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> wrote:
>
> On Tue, 2022-09-13 at 11:47 +0300, Nikita Malakhov wrote:
> > On Tue, Sep 13, 2022 at 11:06 AM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> wrote:
> > > Shouldn't such tuples be considered dead right away, even if the inserting
> > > transaction is still active? That would allow cleaning them up even before
> > > the transaction is done.
> > >
> > > There is this code in HeapTupleSatisfiesVacuumHorizon:
> > >
> > > else if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmin(tuple)))
> > > {
> > > [...]
> > > /* inserted and then deleted by same xact */
> > > if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetUpdateXid(tuple)))
> > > return HEAPTUPLE_DELETE_IN_PROGRESS;
> > >
> > > Why HEAPTUPLE_DELETE_IN_PROGRESS and not HEAPTUPLE_DEAD?
> >
> > Please correct me if I'm wrong, despite tuples being inserted and deleted by the same
> > transaction - they are visible inside the transaction and usable by it, so considering them
> > dead and cleaning up during execution is a bad idea until the transaction is ended.
>
> But once they are deleted or updated, even the transaction that created them cannot
> see them any more, right?
Forgive me if this is not related but if there is a savepoint between
the insertion and deletion, wouldn't it be possible for the
transaction to recover the deleted tuples?
Best regards
Pantelis Theodosiou
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Kapila | 2022-09-13 10:49:59 | Re: Perform streaming logical transactions by background workers and parallel apply |
Previous Message | Kyotaro Horiguchi | 2022-09-13 10:26:29 | Re: Assertion failure in WaitForWALToBecomeAvailable state machine |