pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pengchengliu <pengchengliu@tju.edu.cn>
To: 'Greg Nancarrow' <gregn4422@gmail.com>
Cc: 'Andres Freund' <andres@anarazel.de>
Cc: 'PostgreSQL-development' <pgsql-hackers@postgresql.org>
Subject: RE: Re: Parallel scan with SubTransGetTopmostTransaction assert coredump
Date: Thu, 20 May 2021 09:18:46 +0800
Message-ID: <000801d74d16$150494c0$3f0dbe40$@tju.edu.cn> (raw)
In-Reply-To: <CAJcOf-dD-428NkhDKm8GKTDVU97LYUeOd=RazhLR9boxO_ywsA@mail.gmail.com>
References: <CAJcOf-cJfLcgxwz8TeTZqWe3z2XdLkZAT8gHTwgHqHP9-Cb-Mw@mail.gmail.com>
	<AMkAGwA2DuDLiuCUBBPk1KoS.3.1621046249310.Hmail.2008202116@tju.edu.cn>
	<CAJcOf-eDcGVUx0+HjeYzj73AK+x2OOLEQLcfPn4ThEG9pwZpSw@mail.gmail.com>
	<000901d74b84$fa262890$ee7279b0$@tju.edu.cn>
	<CAJcOf-dD-428NkhDKm8GKTDVU97LYUeOd=RazhLR9boxO_ywsA@mail.gmail.com>

Hi Greg,
   Thanks a lot for you explanation and your fix.
   
   I think your fix can resolve the core dump issue. As with your fix, parallel process reset Transaction Xmin from ActiveSnapshot. 
   But it will change Transaction snapshot for all parallel  scenarios. I don't know whether it bring in other issue. 
   For test only, I think it is enough. 

   So is there anybody can explain what's exactly difference between ActiveSnapshot and TransactionSnapshot in parallel work process. 
   Then maybe we can find a better solution and try to fix it really.

Thanks
Pengcheng 

-----Original Message-----
From: Greg Nancarrow <gregn4422@gmail.com> 
Sent: 2021年5月18日 17:15
To: Pengchengliu <pengchengliu@tju.edu.cn>
Cc: Andres Freund <andres@anarazel.de>; PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: Re: Parallel scan with SubTransGetTopmostTransaction assert coredump

On Tue, May 18, 2021 at 11:27 AM Pengchengliu <pengchengliu@tju.edu.cn> wrote:
>
> Hi Greg,
>
>    Actually I am very confused about ActiveSnapshot and TransactionSnapshot. I don't know why main process send ActiveSnapshot and TransactionSnapshot separately.  And what is exact difference between them?
>    If you know that, could you explain that for me? It will be very appreciated.

In the context of a parallel-worker, I am a little confused too, so I can't explain it either.
It is not really explained in the file
"src\backend\access\transam\README.parallel", it only mentions the following as part of the state that needs to be copied to each worker:

 - The transaction snapshot.
 - The active snapshot, which might be different from the transaction snapshot.

So they might be different, but exactly when and why?

When I debugged a typical parallel-SELECT case, I found that prior to plan execution, GetTransactionSnapshot() was called and its return value was stored in both the QueryDesc and the estate (es_snapshot), which was then pushed on the ActiveSnapshot stack. So by the time
InitializeParallelDSM() was called, the (top) ActiveSnapshot was the last snapshot returned from GetTransactionSnapshot().
So why InitializeParallelDSM() calls GetTransactionSnapshot() again is not clear to me (because isn't then the ActiveSnapshot a potentially earlier snapshot? - which it shouldn't be, AFAIK. And also, it's then different to the non-parallel case).

>    Before we know them exactly, I think we should not modify the TransactionSnapshot to ActiveSnapshot in main process. If it is, the main process should send ActiveSnapshot only.

I think it would be worth you trying my suggested change (if you have a development environment, which I assume you have). Sure, IF it was deemed a proper solution, you'd only send the one snapshot, and adjust accordingly in ParallelWorkerMain(), but we need not worry about that in order to test it.


Regards,
Greg Nancarrow
Fujitsu Australia





view thread (62+ messages)  latest in thread

Message-ID: <000801d74d16$150494c0$3f0dbe40$@tju.edu.cn>
Permalink:  ../000801d74d16$150494c0$3f0dbe40$@tju.edu.cn/
Also on:    postgresql.org/message-id/000801d74d16$150494c0$3f0dbe40$@tju.edu.cn

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: pengchengliu@tju.edu.cn, gregn4422@gmail.com, andres@anarazel.de
  Subject: RE: Re: Parallel scan with SubTransGetTopmostTransaction assert coredump
  In-Reply-To: <000801d74d16$150494c0$3f0dbe40$@tju.edu.cn>

* 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