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 1ixHH4-0002S3-ON for pgsql-bugs@arkaria.postgresql.org; Thu, 30 Jan 2020 21:22:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ixHH3-0003kr-Aw for pgsql-bugs@arkaria.postgresql.org; Thu, 30 Jan 2020 21:22:53 +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 1ixHH2-0003kk-RG for pgsql-bugs@lists.postgresql.org; Thu, 30 Jan 2020 21:22:53 +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 1ixHGz-00084t-8G for pgsql-bugs@lists.postgresql.org; Thu, 30 Jan 2020 21:22:52 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id DAF1F21C6239; Fri, 31 Jan 2020 00:22:47 +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 9F7F621C6237; Fri, 31 Jan 2020 00:22:47 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1580419367; bh=VqqPxPnWMeUwRDmlu4gir0Zs8ac9uPpQPcFQM/saamc=; h=References:From:To:Cc:Subject:In-reply-to:Date; b=fZtBwy4R2FdvPLGbFZM5W+xaSfTV2fOHsPPPC4PhcyeYHr3jySA0b8Z0juFqKHt4y FizO0nMbcdwQovqIL+n9ybXZYTLHz0+6nuxoQpQBJjXoDcqn58B1fYAnEXPKpym04L UYLL7VRK09VHM3WMil/fP8LwixNaEKiejUy6P2Qc= References: <87ftjifoql.fsf@ars-thinkpad> <20191024213157.7pm6niybfxgpvmgg@alap3.anarazel.de> <87eez1fh48.fsf@ars-thinkpad> <87k185ba4x.fsf@ars-thinkpad> <87o8w7vv8h.fsf@ars-thinkpad> User-agent: mu4e 1.1.0; emacs 26.0.50 From: Arseny Sher To: Dan Katz Cc: Andres Freund , Alvaro Herrera , "Hsu\, John" , "pgsql-bugs\@lists.postgresql.org" Subject: Re: ERROR: subtransaction logged without previous top-level txn record In-reply-to: Date: Fri, 31 Jan 2020 00:22:46 +0300 Message-ID: <87ftfwwsex.fsf@ars-thinkpad> MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, Dan Katz writes: > Arseny, > > I was hoping you could give me some insights about how this bug might > appear with multiple replications slots. For example if I have two > replication slots would you expect both slots to see the same error, even > if they were started, consumed or the LSN was confirmed-flushed at > different times? Well, to encounter this you must happen to interrupt decoding session (e.g. shutdown server) when restart_lsn (LSN since WAL will be read next time) is at unfortunate position, as described in https://www.postgresql.org/message-id/87ftjifoql.fsf%40ars-thinkpad Generally each slot has its own restart_lsn, so if one decoding session stucked on this issue, another one won't necessarily fail at the same time. However, restart_lsn can be advanced only to certain points, mainly xl_running_xacts records, which is logged every 15 seconds. So if all consumers acknowledge changes fast enough, it is quite likely that during shutdown restart_lsn will be the same for all slots -- which means either all of them will stuck on further decoding or all of them won't. If not, different slots might have different restart_lsn and probably won't fail at the same time; but encountering this issue even once suggests that your workload makes possibility of such problematic restart_lsn perceptible (i.e. many subtransactions). And each restart_lsn probably has approximately the same chance to be 'bad' (provided the workload is even). We need a committer familiar with this code to look here... -- Arseny Sher Postgres Professional: http://www.postgrespro.com The Russian Postgres Company