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 1ljXL5-0001ZL-FY for pgsql-hackers@arkaria.postgresql.org; Thu, 20 May 2021 01:19:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ljXL4-0004P2-D3 for pgsql-hackers@arkaria.postgresql.org; Thu, 20 May 2021 01:19:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ljXL4-0004MA-4u for pgsql-hackers@lists.postgresql.org; Thu, 20 May 2021 01:19:02 +0000 Received: from mail-m17670.qiye.163.com ([59.111.176.70]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ljXKy-0004lh-5d for pgsql-hackers@postgresql.org; Thu, 20 May 2021 01:18:58 +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 917333C0059; Thu, 20 May 2021 09:18:47 +0800 (CST) From: "Pengchengliu" To: "'Greg Nancarrow'" Cc: "'Andres Freund'" , "'PostgreSQL-development'" References: <000901d74b84$fa262890$ee7279b0$@tju.edu.cn> In-Reply-To: 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> 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/yFluQK3oWxFAlVwYVECpyrQLQG/qomyqTXdq9A= Content-Language: zh-cn X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZGkgeGlZDGBgaHxpDSxpJHxhVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWUFZT0tIVUpKS0 hKTFVLWQY+ X-HM-Sender-Digest: e1kMHhlZQQ8JDh5XWRIfHhUPWUFZRzo6EDpPHD8fPwkRKTUiCBEqHSE9 AgoKCFVKVUpNSUpPTEhOSUxDSUxVMxYaEhdVCx4VHBgTHhUcFxIOOw8RDlUeHw5VGBVFWVdZEgtZ QVlJSkNVSVVCTFVCSVlXWQgBWUFPQk5ONwY+ X-HM-Tid: 0a79875a872cda5akuws917333c0059 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Greg, Thanks a lot for you explanation and your fix. =20 I think your fix can resolve the core dump issue. As with your fix, = parallel process reset Transaction Xmin from ActiveSnapshot.=20 But it will change Transaction snapshot for all parallel scenarios. = I don't know whether it bring in other issue.=20 For test only, I think it is enough.=20 So is there anybody can explain what's exactly difference between = ActiveSnapshot and TransactionSnapshot in parallel work process.=20 Then maybe we can find a better solution and try to fix it really. Thanks Pengcheng=20 -----Original Message----- From: Greg Nancarrow =20 Sent: 2021=E5=B9=B45=E6=9C=8818=E6=97=A5 17:15 To: Pengchengliu Cc: Andres Freund ; PostgreSQL-development = Subject: Re: Re: Parallel scan with SubTransGetTopmostTransaction assert = coredump On Tue, May 18, 2021 at 11:27 AM Pengchengliu = 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