Re: XTM & parallel search

From: Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: XTM & parallel search
Date: 2016-06-03 13:19:13
Message-ID: 575183D1.7010700@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 03.06.2016 16:05, Amit Kapila wrote:
> On Fri, Jun 3, 2016 at 1:34 AM, Konstantin Knizhnik
> <k(dot)knizhnik(at)postgrespro(dot)ru <mailto:k(dot)knizhnik(at)postgrespro(dot)ru>> wrote:
>
> We have to add three more functions to eXtensible Transaction
> Manager API (XTM):
>
> /*
> * Calculate transaction state size. This method is invoked by
> EstimateTransactionStateSpace to copy transaction
> * state to parallel workers
> */
> size_t (*GetTransactionStateSize)(void);
>
> /*
> * Serialize transaction state
> */
> void (*SerializeTransactionState)(void* ctx);
>
> /*
> * Deserialize transaction state
> */
> void (*DeserializeTransactionState)(void* ctx);
>
>
>
> In above proposal, are you suggesting to change the existing API's as
> well, because the parameters of function pointers don't match with
> exiting API's. I think it is better to consider this along with the
> overall XTM API.

Sorry, but right now I have not replaced existed functions
EstimateTransactionStateSpace/SerializeTransactionState/StartParallelWorkerTransaction
with XTM indirect calls. If was my original intention, but these
functions access static variable CurrentTransactionState defined in xact.c.
So if user-defined TM wants to override this functions, it will have to
invoke original functions to save/restore CurrentTransactionState.
It is not convenient.
This is why three XTM functions above are now called by existed xact
funcations to save additional state, for example:

Size
EstimateTransactionStateSpace(void)
{
TransactionState s;
Size nxids = 6; /* iso level, deferrable, top &
current XID,
* command counter, XID count */

for (s = CurrentTransactionState; s != NULL; s = s->parent)
{
if (TransactionIdIsValid(s->transactionId))
nxids = add_size(nxids, 1);
nxids = add_size(nxids, s->nChildXids);
}

nxids = add_size(nxids, nParallelCurrentXids);
nxids = mul_size(nxids, sizeof(TransactionId));
return add_size(nxids, TM->GetTransactionStateSize());
}

--
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-06-03 13:39:43 Re: Rename max_parallel_degree?
Previous Message Amit Kapila 2016-06-03 13:05:30 Re: XTM & parallel search