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 1pN7HP-0006Ue-Vo for pgsql-general@arkaria.postgresql.org; Wed, 01 Feb 2023 07:11:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pN7HO-00052F-Nb for pgsql-general@arkaria.postgresql.org; Wed, 01 Feb 2023 07:11:38 +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 1pN7HO-0004zx-Ab for pgsql-general@lists.postgresql.org; Wed, 01 Feb 2023 07:11:38 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pN7HK-0000Vh-CW for pgsql-general@lists.postgresql.org; Wed, 01 Feb 2023 07:11:37 +0000 Received: by mail-pj1-x1034.google.com with SMTP id nm12-20020a17090b19cc00b0022c2155cc0bso1078385pjb.4 for ; Tue, 31 Jan 2023 23:11:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=pmIdgnFo09R2NpT/yJ9dBSKpFB+5/iaza+QBG/4Gmyc=; b=iOLH+iY16DTYqncmKzyAM2W1Q3NJ7efK9ZnaUbHO7HQXYUfk8LqQiVxhZKyVnA8kDW lJTzCYbT8pp5fJlVvQ1aqq96OXfp4GR/Nx80CFT+nXb337Aqit+NIRhIAUuUEHvRs7v4 92nQcpWo3QhRvv9txXu5qdzY8YkNoqxQ/YKGlbiz96/mgnqFBELy94pGYktFsca0fflq cl/a0EuPrOwePyea7uGgnZqXm7bStRxXR7V1Pw9rFqd/mAWvftj4bMeyngoJV2kwc7Gx hgQ6LH5Zdg5RWkp8HKPwj4wG9BW2/BqG1QSFuGYBpwxcOHygLN2sLcAo/DGUEHdCaMAT ca5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=pmIdgnFo09R2NpT/yJ9dBSKpFB+5/iaza+QBG/4Gmyc=; b=0SCItRel72ZZX3F0YgOIMY+lGK1s7qSoeYpFRbK23MPqPXMc09+cCJBjQJ3Q0uzItJ 80GXpABD3Y9vVhw0iOiq5SgmwBQzPEW5Yc1uZjan4woeLHCDrdvbwjjUOOWKiD6bbKH2 N6q/gdEXozjcZOgIKxvo+CU/Fs24DswMbf2Fv2gM1CnphFKepWo4Siwjw7N+VIY7PUjj OpAjh4HvuD7cvkYzh7044thSuok0Fc/r1VL/1gopUL9z7CYHR3Z2VBsTraC/uNVnrm9a alc3HOvMEt+B6/pnN8Ed53MTW/XJFSltklMVW/ybAaxF+tOmmP3985erQKpXw0Fo48Ck YjkA== X-Gm-Message-State: AO0yUKW/GPsMdHkyM8UyfGp4qgU7xj9QWCsXxfPU0wx7s4hZ0R0EhNQI OmMweHvpQj4Cu36Q0Xld5CY= X-Google-Smtp-Source: AK7set/X8B8LjIOlQeBsrPFdGtuqdNWeLwbAZHNUPK1Zc8bi/ifakBn3TYkMmM4FNh5D5DL7/FLcYg== X-Received: by 2002:a17:902:e54d:b0:196:8056:9d11 with SMTP id n13-20020a170902e54d00b0019680569d11mr2240480plf.40.1675235491888; Tue, 31 Jan 2023 23:11:31 -0800 (PST) Received: from jrouhaud (2001-b011-1005-541f-a805-9f20-8f5c-a425.dynamic-ip6.hinet.net. [2001:b011:1005:541f:a805:9f20:8f5c:a425]) by smtp.gmail.com with ESMTPSA id w9-20020a170902d3c900b0019337bf957dsm10913835plb.296.2023.01.31.23.11.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 23:11:31 -0800 (PST) Date: Wed, 1 Feb 2023 15:11:28 +0800 From: Julien Rouhaud To: qihua wu Cc: pgsql-general@lists.postgresql.org Subject: Re: invisible commit question for sync replication Message-ID: <20230201071128.zhhff44qlbahsc6h@jrouhaud> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Wed, Feb 01, 2023 at 02:52:49PM +0800, qihua wu wrote: > When run a cluster with sync replication, if DML is done on primary, but > primary is isolated from all slave, then the DML will hang, if cancel it > DML, it will say: > WARNING: canceling wait for synchronous replication due to user request > DETAIL: The transaction has already committed locally, but might not have > been replicated to the standby > > So the workflow is > 1: commit to local. > 2: waiting for ACK from remote sync. > > When cancel the DML at step 2. the data are arealy on local, that's why > it's warning. > > But when runs an insert which is waiting for remote ACK, and then query > from another session, I didn't find that row. Why this happen? If the > insert is already one locally, whey another session can't read it? It works as expected for me, are you sure both sessions are actually connected to the same server and/or querying the same table? [1456]rjuju@127.0.0.1:14295) rjuju=# select * from tt; id | val ----+----- (0 rows) [1456]rjuju@127.0.0.1:14295) rjuju=# insert into tt select 1; ^CCancel request sent WARNING: 01000: canceling wait for synchronous replication due to user request DETAIL: The transaction has already committed locally, but might not have been replicated to the standby. LOCATION: SyncRepWaitForLSN, syncrep.c:287 INSERT 0 1 [1456]rjuju@127.0.0.1:14295) rjuju=# select pg_backend_pid(), * from tt; pg_backend_pid | id | val ----------------+----+-------- 1456 | 1 | (1 row) and another session: [3327]rjuju@127.0.0.1:14295) rjuju=# select pg_backend_pid(), * from tt; pg_backend_pid | id | val ----------------+----+-------- 3327 | 1 | (1 row)