Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lioWT-0002YV-Rr for pgsql-hackers@arkaria.postgresql.org; Tue, 18 May 2021 01:27:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lioWR-0006I9-OK for pgsql-hackers@arkaria.postgresql.org; Tue, 18 May 2021 01:27:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lioWR-0006GY-G2 for pgsql-hackers@lists.postgresql.org; Tue, 18 May 2021 01:27:47 +0000 Received: from mail-m17670.qiye.163.com ([59.111.176.70]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lioWL-0001RS-7l for pgsql-hackers@postgresql.org; Tue, 18 May 2021 01:27:43 +0000 Received: from activesync-2-hmail-entmail-virt40.dg.163.org (localhost [127.0.0.1]) by mail-m17670.qiye.163.com (Hmail) with ESMTP id 405B83C00E2; Tue, 18 May 2021 09:27:34 +0800 (CST) From: "Pengchengliu" To: "'Greg Nancarrow'" Cc: "'Andres Freund'" , "'PostgreSQL-development'" References: In-Reply-To: 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> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQKMVnF2uVfQC+5xVzv7kF3C/yFluQK3oWxFAlVwYVGpVexukA== Content-Language: zh-cn X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZQx5KGFYYSh5CTh9NTBhLS0pVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWUFZT0tIVUpKS0 hKTFVLWQY+ X-HM-Sender-Digest: e1kMHhlZQQ8JDh5XWRIfHhUPWUFZRzozTTo#DDgePxARNDVOECIiDRdO IgoKKlVKVUpNSUpIS0pJTk9OTUlVMxYaEhdVCx4VHBgTHhUcFxIOOw8RDlUeHw5VGBVFWVdZEgtZ QVlJSkNVSVVCTFVCSVlXWQgBWUFPTUNDNwY+ X-HM-Tid: 0a797d15d878da5akuws405b83c00e2 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. =20 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. =20 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.=20 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. =20 Thanks Pengcheng =20 =20 -----Original Message----- From: Greg Nancarrow =20 Sent: 2021=E5=B9=B45=E6=9C=8817=E6=97=A5 20:59 To: =E5=88=98=E9=B9=8F=E7=A8=8B Cc: Andres Freund ; PostgreSQL-development = Subject: Re: Re: Parallel scan with SubTransGetTopmostTransaction assert = coredump On Sat, May 15, 2021 at 12:37 PM =E5=88=98=E9=B9=8F=E7=A8=8B = 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 --- 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 =3D DSM_HANDLE_INVALID; - Snapshot transaction_snapshot =3D GetTransactionSnapshot(); + Snapshot transaction_snapshot =3D GetActiveSnapshot(); Snapshot active_snapshot =3D GetActiveSnapshot(); /* We might be running in a very short-lived memory context. */