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 1pGZ8j-0004HB-Uz for pgsql-general@arkaria.postgresql.org; Sat, 14 Jan 2023 05:31:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pGZ8i-0008DI-Jo for pgsql-general@arkaria.postgresql.org; Sat, 14 Jan 2023 05:31:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pGZ8i-0008D9-9N for pgsql-general@lists.postgresql.org; Sat, 14 Jan 2023 05:31:36 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pGZ8c-0001Nx-V1 for pgsql-general@lists.postgresql.org; Sat, 14 Jan 2023 05:31:35 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 30E5VS5f920091; Sat, 14 Jan 2023 00:31:28 -0500 From: Tom Lane To: qihua wu cc: pgsql-general@lists.postgresql.org Subject: Re: synchronized standby: committed local and waiting for remote ack In-reply-to: References: Comments: In-reply-to qihua wu message dated "Sat, 14 Jan 2023 11:16:56 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <920089.1673674288.1@sss.pgh.pa.us> Date: Sat, 14 Jan 2023 00:31:28 -0500 Message-ID: <920090.1673674288@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk qihua wu writes: > We are using patroni to set up 1 primary and 5 slaves, and using ANY 2 (*) > to commit a transaction if any 2 standbys receive the WAL. If there is a > network partitioning between the primary and the slave, then commit will > hang from user perspective, but the commit is actually done locally, just > waiting for remote ack which is not possible because of network split. And > if patroni promotes a slave to primary, then we will lost data. Do you > think of a different design: first wait for remote ACK, and then commit > locally, this will only failed if local commit failed, but local commit > fail is much rarer than network partitioning in a cloud env: it will only > fail when IO issue or disk is full. So I am thinking of the possibility of > switch the order: first wait for remote ACK, and then commit locally. That just gives you a different set of failure modes. It'd be particularly bad if you have more than one standby, because you could easily get into a situation where *none* of the nodes represent truth. regards, tom lane