Re: COPY, lock release and MVCC

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY, lock release and MVCC
Date: 2020-05-13 20:36:40
Message-ID: ed6f3e0064abb75538439377750c8d2e7d82f9f0.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 2020-05-13 at 19:29 +0530, Amit Kapila wrote:
> > > > > On Fri, May 8, 2020 at 4:58 AM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> wrote:
> > > > > > I happened to notice that COPY TO releases the ACCESS SHARE lock
> > > > > > on the table right when the command ends rather than holding it
> > > > > > until the end of the transaction:
> >
> > Here is a patch.
> >
>
> - /*
> - * Close the relation. If reading, we can release the AccessShareLock we
> - * got; if writing, we should hold the lock until end of transaction to
> - * ensure that updates will be committed before lock is released.
> - */
> - if (rel != NULL)
> - table_close(rel, (is_from ? NoLock : AccessShareLock));
> + table_close(rel, NoLock);
>
> I wonder why you have removed (rel != NULL) check?

That was just unexcusable sloppiness, nothing more.

Here is a fixed patch.

Yours,
Laurenz Albe

Attachment Content-Type Size
0001-Make-COPY-TO-keep-locks-until-transaction-end.v2.patch text/x-patch 1.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chapman Flack 2020-05-13 21:01:18 Re: JSON output from psql
Previous Message Gurjeet Singh 2020-05-13 20:16:20 Re: JSON output from psql