Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j0p7t-0001uI-EJ for pgsql-bugs@arkaria.postgresql.org; Sun, 09 Feb 2020 16:08:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j0p7s-0001bB-6e for pgsql-bugs@arkaria.postgresql.org; Sun, 09 Feb 2020 16:08:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j0p7r-0001b4-Qf for pgsql-bugs@lists.postgresql.org; Sun, 09 Feb 2020 16:08:03 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1j0p7k-0000uU-Gv for pgsql-bugs@lists.postgresql.org; Sun, 09 Feb 2020 16:08:03 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 00D6921C4BE9; Sun, 9 Feb 2020 19:07:54 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from ars-thinkpad (nat03-43-2.netorn.net [188.35.130.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id B07F021C4BDA; Sun, 9 Feb 2020 19:07:54 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1581264474; bh=/pgWxH+o4GNfowvWdXaxvrYHNCqYBQrFdVPLuJQgX+o=; h=References:From:To:Cc:Subject:In-reply-to:Date; b=SylkPgjN5plw5zWgi0fAQHQIhWEQir2kIBD+bUMJlmA1r6jfVnOuagkW0HBiBWDhW uigCAeZWqjt4WKM2qXq1aLwusNS8OBlpssD4XvUPrpMHvk8nIUk2vle+OJZKygCIh/ WbrHhsfSUNUQVq469+idsotgEQYI5ssQgCzK53Jg= References: <87ftjifoql.fsf@ars-thinkpad> <20191024213157.7pm6niybfxgpvmgg@alap3.anarazel.de> <87eez1fh48.fsf@ars-thinkpad> <8736bs81sx.fsf@ars-thinkpad> <871rrb942q.fsf@ars-thinkpad> <87zhdx76d5.fsf@ars-thinkpad> User-agent: mu4e 1.1.0; emacs 26.0.50 From: Arseny Sher To: Amit Kapila Cc: Andres Freund , "Hsu\, John" , "pgsql-bugs\@lists.postgresql.org" Subject: Re: ERROR: subtransaction logged without previous top-level txn record In-reply-to: Date: Sun, 09 Feb 2020 19:07:50 +0300 Message-ID: <8736bjoiax.fsf@ars-thinkpad> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --=-=-= Content-Type: text/plain Amit Kapila writes: >> 1) Decoding from existing slot (*not* initial snapshot construction) >> starts up, immediately picks up snapshot at restart_lsn (getting into >> SNAPBUILD_CONSISTENT) and in some xl_xact_assignment learns that it >> hadn't seen in full (no toplevel records) transaction which it is not >> even going to stream -- but still dies with "subtransation logged >> without...". That's my example above, and that's what people are >> complaining about. Here, usage of serialized snapshot and jump to >> SNAPBUILD_CONSISTENT is not just legit, it is essential: or order to be >> able to stream data since confirmed_flush_lsn, we must pick it up as we >> might not be able to assemble it from scratch in time. I mean, what is >> wrong here is not serialized snapshot usage but the check. >> > > I was thinking if we have some way to skip processing of > xl_xact_assignment for such cases, then it might be better. Say, > along with restart_lsn, if have some way to find corresponding nextXid > (below which we don't need to process records). I don't believe you can that without persisting additional data. Basically, what we need is list of transactions who are running at the point of snapshot serialization *and* already wrote something before it -- those we hadn't seen in full and can't decode. We have no such data currently. The closest thing we have is xl_running_xacts->nextXid, but 1) issued xid doesn't necessarily means xact actually wrote something, so we can't just skip xl_xact_assignment for xid < nextXid, it might still be decoded 2) snapshot might be serialized not at xl_running_xacts anyway Surely this thing doesn't deserve changing persisted data format. Somehow I hadn't realized this earlier, so my comments/commit messages in patches above were not accurate here; I've edited them. Also in the first patch serialized snapshots are not no longer used for new slot creation at all, as Andres suggested above. This is not principal, as I said, but arguably makes things simpler a bit. I've also found a couple of issues with slot copying feature, will post in separate thread on them. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Don-t-use-serialized-snapshots-during-logical-slo-v2.patch