pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: tsunakawa.takay@fujitsu.com <tsunakawa.takay@fujitsu.com>
To: Robert Haas <robertmhaas@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Amit Kapila <akapila@postgresql.org>
Cc: pgsql-committers <pgsql-committers@lists.postgresql.org>
Subject: RE: pgsql: Add a new GUC and a reloption to enable inserts in parallel-mode
Date: Fri, 26 Mar 2021 09:28:49 +0000
Message-ID: <TYAPR01MB2990BC344B1C307CF5C3BC37FE619@TYAPR01MB2990.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <CA+TgmobaQFUBkVOsmdOt9ag=3g0WjKfefP8ys1TV5GhHELfLOA@mail.gmail.com>
References: <E1lMiB9-0001c3-SY@gemulon.postgresql.org>
	<CA+TgmoY0GdS7POPWB2nG3yiycNeLz05Mw53NunOjn8f8rZZuxw@mail.gmail.com>
	<558385.1616423602@sss.pgh.pa.us>
	<CAA4eK1+vRWCjMyNJKi+Jk=aOVdH0OuD+ShxTFXchHKH8=yTN9Q@mail.gmail.com>
	<20210323191307.twhewx7vqj2ocglv@alap3.anarazel.de>
	<CA+TgmoazkgAyyMiOy7t2cCRX-VpWUULAOxx+5mb92WCTvkyDmA@mail.gmail.com>
	<20210324044840.ed65i3w7prlssfmd@alap3.anarazel.de>
	<CA+TgmobaQFUBkVOsmdOt9ag=3g0WjKfefP8ys1TV5GhHELfLOA@mail.gmail.com>

From: Robert Haas <robertmhaas@gmail.com>
> On Wed, Mar 24, 2021 at 12:48 AM Andres Freund <andres@anarazel.de>
> wrote:
> > Although this specific hack doesn't seem too terrible to me. If you
> > execute a parallel insert the likelihood to end up not needing an xid is
> > pretty low. Implementing it concurrently does seem like it'd end up
> > needing another lwlock nested around xid assignment, or some more
> > complicated scheme with already holding XidGenLock or retries. But maybe
> > I'm missing an easy solution here.
> 
> I don't think you need to do anything that is known outside the group
> of processes involved in the parallel query. I think you just need to
> make sure that only one of them is trying to acquire an XID at a time,
> and that all the others find out about it. I haven't thought too hard
> about the timing: if one process acquires an XID for the transaction,
> is it OK if the others do an arbitrary amount of work before they
> realize that this has happened? Also, there's the problem that the
> leader has the whole transaction stack and the workers don't, so the
> recursive nature of XID acquisition is a problem. I suspect these are
> all pretty solvable problems; I just haven't put in the energy. But,
> it could also be that I'm missing something.

It doesn't seem easy to make parallel workers allocate an XID and share it among the parallel processes.  When the DML is run inside a deeply nested subtransaction and the parent transactions have not allocated their XIDs yet, the worker needs to allocate the XIDs for its parents.  That indeterminate number of XIDs must be stored in shared memory.  The stack of TransactionState structures must also be passed.  Also, TransactionIdIsCurrentTransactionId() uses an array ParallelCurrentXids where parallel workers receive sub-committed XIDs from the leader.  This needs to be reconsidered.

Before that, I don't see the need for parallel workers to allocate the XID.  As the following Oracle manual says, parallel DML will be used in data analytics and OLTP batch jobs.  There should be plenty of source data in those scenarios.


When to Use Parallel DML
https://docs.oracle.com/en/database/oracle/oracle-database/21/vldbg/types-parallelism.html#GUID-18B2...
--------------------------------------------------
Several scenarios where parallel DML is used include:

Refreshing Tables in a Data Warehouse System

Creating Intermediate Summary Tables

Using Scoring Tables

Updating Historical Tables

Running Batch Jobs
--------------------------------------------------


I don't mean to say we want to use the easy hack as we want to be lazy.  I'd like to know whether we *really* need the effort.  And I want PostgreSQL to provide great competitive features as early as possible without messing up the design and code.

For what kind of realistic conceivable scenarios do we need the sophisticated XID assignment mechanism in parallel workers?


Regards
Takayuki Tsunakawa




view thread (37+ messages)  latest in thread

Message-ID: <TYAPR01MB2990BC344B1C307CF5C3BC37FE619@TYAPR01MB2990.jpnprd01.prod.outlook.com>
Permalink:  ../TYAPR01MB2990BC344B1C307CF5C3BC37FE619@TYAPR01MB2990.jpnprd01.prod.outlook.com/
Also on:    postgresql.org/message-id/TYAPR01MB2990BC344B1C307CF5C3BC37FE619@TYAPR01MB2990.jpnprd01.prod.outlook.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tsunakawa.takay@fujitsu.com, robertmhaas@gmail.com, andres@anarazel.de, amit.kapila16@gmail.com, tgl@sss.pgh.pa.us, akapila@postgresql.org
  Subject: Re: pgsql: Add a new GUC and a reloption to enable inserts in parallel-mode
  In-Reply-To: <TYAPR01MB2990BC344B1C307CF5C3BC37FE619@TYAPR01MB2990.jpnprd01.prod.outlook.com>
  References: <E1lMiB9-0001c3-SY@gemulon.postgresql.org> <CA+TgmoY0GdS7POPWB2nG3yiycNeLz05Mw53NunOjn8f8rZZuxw@mail.gmail.com> <558385.1616423602@sss.pgh.pa.us> <CAA4eK1+vRWCjMyNJKi+Jk=aOVdH0OuD+ShxTFXchHKH8=yTN9Q@mail.gmail.com> <20210323191307.twhewx7vqj2ocglv@alap3.anarazel.de> <CA+TgmoazkgAyyMiOy7t2cCRX-VpWUULAOxx+5mb92WCTvkyDmA@mail.gmail.com> <20210324044840.ed65i3w7prlssfmd@alap3.anarazel.de> <CA+TgmobaQFUBkVOsmdOt9ag=3g0WjKfefP8ys1TV5GhHELfLOA@mail.gmail.com> <TYAPR01MB2990BC344B1C307CF5C3BC37FE619@TYAPR01MB2990.jpnprd01.prod.outlook.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox