pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Maxim Orlov <m.orlov@postgrespro.ru>
To: Greg Nancarrow <gregn4422@gmail.com>
Cc: Pavel Borisov <pashkin.elfe@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Pengchengliu <pengchengliu@tju.edu.cn>
Cc: Andres Freund <andres@anarazel.de>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: Parallel scan with SubTransGetTopmostTransaction assert coredump
Date: Tue, 22 Jun 2021 18:06:49 +0300
Message-ID: <08ae178b309c617a9701cbc7ed8a98f0@postgrespro.ru> (raw )
In-Reply-To: <09788181118f7bd8000d3bb097e0720f@postgrespro.ru >
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 >
<000801d74d16$150494c0$3f0dbe40$@tju.edu.cn >
<CAJcOf-dVeKS2YJaS_BVdF7ghQ=xFj2d68TzGjYCvzo8cM0FtDQ@mail.gmail.com >
<CAJcOf-c63QJ3X7geemcjtkd7ohHM1=7xJYuv8W6LLRAc9DNvOQ@mail.gmail.com >
<YKswhdCNo6gwn2w2@paquier.xyz >
<CAJcOf-cNLhA7iaUYAQqZ44tz3oHJoPxGRm1+tNE27iJXTXObzQ@mail.gmail.com >
<CALT9ZEG4vzW1C=U4-AvgCA9=QEqVfrxaQ8PQ98CGNZ5LBG96kQ@mail.gmail.com >
<CAJcOf-dX8ufSeCghz9Wg4CrtpJboCxtkqjtK6giLowkwaROcuQ@mail.gmail.com >
<09788181118f7bd8000d3bb097e0720f@postgrespro.ru >
The analysis in the beginning of the discussion seems to be right, but
the fix v2 looks too invasive for me.
Personally, I'd like not to remove snapshot even if transaction is
read-only. I propose to consider "xid < TransactionXmin" as a legit case
and just promote xid to TransactionXmin.
It's annoying this old bug still not fixed. What do you think?
---
Best regards,
Maxim Orlov.
Attachments:
v3-0001-PG14-Fix-parallel-worker-failed-assertion-and-coredump.patch (text/x-diff, 1.2K) download
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 6a8e521f894..ce7c90aa38f 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -29,6 +29,7 @@
#include "postgres.h"
#include "access/slru.h"
+#include "access/parallel.h"
#include "access/subtrans.h"
#include "access/transam.h"
#include "pg_trace.h"
@@ -152,6 +153,21 @@ SubTransGetTopmostTransaction(TransactionId xid)
TransactionId parentXid = xid,
previousXid = xid;
+ /*
+ * We may have different xmins in active and transaction snapshots in
+ * parallel workers. And TransactionXmin can be promoted to the max of them.
+ * So, we do this to avoid assert below when restore active snapshot with
+ * less xmin value.
+ *
+ * XXX: the same may be fixed by prohibiting read-only transactions (like
+ * parallel scans) to increment TransactionXmin.
+ */
+ if (IsParallelWorker())
+ {
+ xid = xid > TransactionXmin ? xid : TransactionXmin;
+ parentXid = xid;
+ previousXid = xid;
+ }
/* Can't ask about stuff that might not be around anymore */
Assert(TransactionIdFollowsOrEquals(xid, TransactionXmin));
view thread (62+ messages) latest in thread
Message-ID: <08ae178b309c617a9701cbc7ed8a98f0@postgrespro.ru>
Permalink: ../08ae178b309c617a9701cbc7ed8a98f0@postgrespro.ru/
Also on: postgresql.org/message-id/08ae178b309c617a9701cbc7ed8a98f0@postgrespro.ru
copy link · copy postgr.es · copy git am
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: m.orlov@postgrespro.ru, gregn4422@gmail.com, pashkin.elfe@gmail.com, michael@paquier.xyz, pengchengliu@tju.edu.cn, andres@anarazel.de
Subject: Re: Parallel scan with SubTransGetTopmostTransaction assert coredump
In-Reply-To: <08ae178b309c617a9701cbc7ed8a98f0@postgrespro.ru>
* 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