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 1pQUR2-0008Ik-Pd for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Feb 2023 14:31:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pQUR1-0004Zw-JN for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Feb 2023 14:31:31 +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 1pQUR1-0004Zn-7G for pgsql-bugs@lists.postgresql.org; Fri, 10 Feb 2023 14:31:31 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pQUQy-0007RP-BE for pgsql-bugs@lists.postgresql.org; Fri, 10 Feb 2023 14:31:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=In-Reply-To:Content-Type:MIME-Version:References:Reply-To: Message-ID:Subject:Cc:To:Sender:From:Date:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=V7RPZS5gEMTamyf4cjyajSYrd0/LGMBjGgMj0wy9EiE=; b=r66xbM2p7tVCMNN5RsZ6y2tAqC b9QeOp8FMwkbXiKP/23Ll4BAsP6H5TblIOhwVp15DRuf5lLFZoUlWYMXAJptfRfdrl6dS1e9oYOm8 v3G7JmnyLGXcQj2UKeoTv1OshpMsFDqcxfKqMnlQrV5aenoT+W9cVZKdCJ5RFXox2k7E=; Received: from depesz by depesz.com with local (Exim 4.94.2) (envelope-from ) id 1pQUQv-00BES9-0C; Fri, 10 Feb 2023 15:31:25 +0100 Date: Fri, 10 Feb 2023 15:31:24 +0100 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: Masahiko Sawada Cc: Amit Kapila , PostgreSQL mailing lists Subject: Re: WAL segments removed from primary despite the fact that logical replication slot needs it. Message-ID: Reply-To: depesz@depesz.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, so, we have another bit of interesting information. maybe related, maybe not. We noticed weird situation on two clusters we're trying to upgrade. In both cases sitaution looked the same: 1. there was another process (debezium) connected to source (pg12) using logical replication 2. pg12 -> pg14 replication failed with the message 'ERROR: requested WAL segment ... has already been ' 3. some time afterwards (most likely couple of hours) the process that is/was responsible for debezium replicaiton (pg process) stopped handling WAL, but instead is eating 100% of cpu. When this situation happens, we can't pg_cancel_backend(pid) for the "broken" wal sender, it also can't be pg_terminate_backend() ! strace of the process doesn't show anything. When I tried to get backtrace from gdb all I got was: (gdb) bt #0 0x0000aaaad270521c in hash_seq_search () #1 0x0000ffff806c86cc in ?? () from /usr/lib/postgresql/12/lib/pgoutput.so #2 0x0000aaaad26e3644 in CallSyscacheCallbacks () #3 0x0000aaaad26e3644 in CallSyscacheCallbacks () #4 0x0000aaaad257764c in ReorderBufferCommit () #5 0x0000aaaad256c804 in ?? () #6 0x0000aaaaf303d280 in ?? () If I'd quit gdb, and restart, and redo bt, I get #0 0x0000ffff806c81a8 in hash_seq_search@plt () from /usr/lib/postgresql/12/lib/pgoutput.so #1 0x0000ffff806c86cc in ?? () from /usr/lib/postgresql/12/lib/pgoutput.so #2 0x0000aaaad291ae58 in ?? () or #0 0x0000aaaad2705244 in hash_seq_search () #1 0x0000ffff806c86cc in ?? () from /usr/lib/postgresql/12/lib/pgoutput.so #2 0x0000aaaad26e3644 in CallSyscacheCallbacks () #3 0x0000aaaad26e3644 in CallSyscacheCallbacks () #4 0x0000aaaad257764c in ReorderBufferCommit () #5 0x0000aaaad256c804 in ?? () #6 0x0000aaaaf303d280 in ?? () At this moment, the only thing that we can do is kill -9 the process (or restart pg). I don't know if it's relevant, but I have this case *right now*, and if it's helpful I can provide more information before we will have to kill it. Best regards, depesz