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: Tue, 18 May 2021 09:27:33 +0800
Message-ID: <000901d74b84$fa262890$ee7279b0$@tju.edu.cn> (raw)
In-Reply-To: <CAJcOf-eDcGVUx0+HjeYzj73AK+x2OOLEQLcfPn4ThEG9pwZpSw@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>

Hi Greg,
  > I actually think that the Assert in SubTransGetTopmostTransaction() is correct, but in the parallel-worker case, the snapshots are not being setup correctly.
  
   I agree with you that Assert in SubTransGetTopmostTransaction() is correct.  The root cause is Transaction Xmin are not being setup correctly in the parallel-worker.
   
   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. 
   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.  

Thanks
Pengcheng
   
   

-----Original Message-----
From: Greg Nancarrow <gregn4422@gmail.com> 
Sent: 2021年5月17日 20:59
To: 刘鹏程 <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 Sat, May 15, 2021 at 12:37 PM 刘鹏程 <pengchengliu@tju.edu.cn> wrote:
>
>
>   BTW, I test it in a high performance server. It is verly easily be reproduced. My colleague and me use different environment both can reproduce it.
>

Hi Pengcheng,

Although the issue won't reproduce easily in my system, I can certainly see how, for the snapshots used in the parallel worker case, the Active snapshot used is potentially an earlier snapshot that the Transaction snapshot. I don't know why it is getting a newer Transaction snapshot in InitializeParallelDSM(), when it has previously pushed the return value of GetTransactionSnapshot() as the Active snapshot.

So I too hope Tom or Robert can explain what is going on here and how to resolve it (as you requested them to, in your other post).

I actually think that the Assert in SubTransGetTopmostTransaction() is correct, but in the parallel-worker case, the snapshots are not being setup correctly.

Can you try the trivial change below and see if it prevents the coredump?

Regards,
Greg Nancarrow
Fujitsu Australia


diff --git a/src/backend/access/transam/parallel.c
b/src/backend/access/transam/parallel.c
index 14a8690019..870889053f 100644
inline patch 1: src/backend/access/transam/parallel.c (+1/-1 lines) download inline-1.patch--- a/src/backend/access/transam/parallel.c +++ b/src/backend/access/transam/parallel.c @@ -216,7 +216,7 @@ InitializeParallelDSM(ParallelContext *pcxt) int i; FixedParallelState *fps; dsm_handle session_dsm_handle = DSM_HANDLE_INVALID; - Snapshot transaction_snapshot = GetTransactionSnapshot(); + Snapshot transaction_snapshot = GetActiveSnapshot(); Snapshot active_snapshot = GetActiveSnapshot(); /* We might be running in a very short-lived memory context. */

view thread (62+ messages)  latest in thread

Message-ID: <000901d74b84$fa262890$ee7279b0$@tju.edu.cn>
Permalink:  ../000901d74b84$fa262890$ee7279b0$@tju.edu.cn/
Also on:    postgresql.org/message-id/000901d74b84$fa262890$ee7279b0$@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: <000901d74b84$fa262890$ee7279b0$@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