Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rhqLd-00DdQd-G3 for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Mar 2024 12:26:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rhqLc-009kMa-0O for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Mar 2024 12:26:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rhqLb-009kMS-Nq for pgsql-hackers@lists.postgresql.org; Wed, 06 Mar 2024 12:26:12 +0000 Received: from mail-oa1-x2c.google.com ([2001:4860:4864:20::2c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rhqLY-00357V-Es for pgsql-hackers@lists.postgresql.org; Wed, 06 Mar 2024 12:26:11 +0000 Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-21f0c82e97fso4278793fac.2 for ; Wed, 06 Mar 2024 04:26:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709727966; x=1710332766; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=fcoJkkA7ms0Da+E6YDZAvKdYLFliEFtTjDaj8GQ/pcU=; b=NITtTNuf/NAsWL6zQOi8t8gVDbIrUavBRNP9vfGwo579gbOvLLxrCRalbSIqZFQIhM JnucMIHHkt65/o/LIXOpuVPQJFqchg9c2NDmFRCh2Q1dnc15UClnwSxxf4ZCgk+IZ+9A EtQDIEwTdgeGmxQHHpTLbcLU7CzaKGPGipawOLG7I22MH37l50+kArKOM7dqvtitrTXL Fj+mAol5jRkdajRP2CREj5dOTBIlyOOad5+NUmEr1eED6L1+ytbuBwH2Ak0ALna0BC6F 6C8Ub1RSVg5pmafpvrR6NXoypHfBMc5/OdDN710Na2juWHkBpWMDiqlQZMlC93misjGI bAJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709727966; x=1710332766; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fcoJkkA7ms0Da+E6YDZAvKdYLFliEFtTjDaj8GQ/pcU=; b=Xd0zfhnpINuWeS92feakea5DAayD5v99DKz+OHFsUD7vJODqQPe4OY4AFOx6IyrQ4r FPGe8o+cSppaMykZzLXLtFr9RWpNqMPOp9e0f6KEYfWW0O40KVj41tTKKrhX/KG61C+t 1IUeC/UOFmHl58ZS2ynb6KXyytxNzv+p6CuYDVjqm56Z+PV9DI55PueCUAKcnSXfPuNz iXRyYSTvftJmNYsGQvZLmTVp3q2Mrt07cMHuEk9vloVGoc2creWvXpEXiUGoeZbPMd9n Q23l5Ml4yIvbP2nmLdBjiVZHfO2hbi6RWtFgmhIgQDRclZ1vlG96eCyYHIlpA/vTgf2g XtcQ== X-Forwarded-Encrypted: i=1; AJvYcCVtMmnLf3Guk9LKza7EmaY86pZowIFgCCj9XIMFKDWdDZvwmu1tngRj6SnPjGtXI5N0fT6Rn8k/nEql0qgqphiKVOkFBmU4so2KKxZx0k3LDlIL X-Gm-Message-State: AOJu0YxJ+CelfVd10dVd8bD8fqyB9gLowx3bR/JHHst+/o6x/83L0Ad/ c9RGCOqu9/BaONGG7Z9EiS3+4gXVwv9Fc5fcHVym4xQuXuk7eRQLsK2KTiyb2FWQED0LCS1DuuL TdxTPrc8Cy4xGgqHPvMCvK1kcg7EJ7MyxjbM= X-Google-Smtp-Source: AGHT+IE0elrkkBiEOVJe9DED+dnTr/cDdc55UHouMuq3nvFjTgEYo8ShYCTJ/m72fLWiwidPbaLOqDFzwNlw2ACfa9c= X-Received: by 2002:a05:6870:970e:b0:220:932f:1a19 with SMTP id n14-20020a056870970e00b00220932f1a19mr5027867oaq.55.1709727966190; Wed, 06 Mar 2024 04:26:06 -0800 (PST) MIME-Version: 1.0 References: <8fab8-65d74c80-1-2f28e880@39088166> <99df2-65d8d200-1-63c26880@172687752> In-Reply-To: From: Amit Kapila Date: Wed, 6 Mar 2024 17:55:54 +0530 Message-ID: Subject: Re: Slow catchup of 2PC (twophase) transactions on replica in LR To: =?UTF-8?B?0JTQsNCy0YvQtNC+0LIg0JLQuNGC0LDQu9C40Lk=?= Cc: Heikki Linnakangas , pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Mar 5, 2024 at 7:59=E2=80=AFPM =D0=94=D0=B0=D0=B2=D1=8B=D0=B4=D0=BE= =D0=B2 =D0=92=D0=B8=D1=82=D0=B0=D0=BB=D0=B8=D0=B9 wrote: > > Thank you for the reply. > > On Tuesday, March 05, 2024 12:05 MSK, Heikki Linnakangas wrote: > > > In a nutshell, this changes PREPARE TRANSACTION so that if > synchronous_commit is 'off', the PREPARE TRANSACTION is not fsync'd to > disk. So if you crash after the PREPARE TRANSACTION has returned, the > transaction might be lost. I think that's completely unacceptable. > > > You are right, the prepared transaction might be lost after crash. The sa= me may happen with regular transactions that are not fsync-ed on replica in= logical replication by default. The subscription parameter synchronous_com= mit is OFF by default. I'm not sure, is there some auto recovery for regula= r transactions? > Unless the commit WAL is not flushed, we wouldn't have updated the replication origin's LSN and neither the walsender would increase the confirmed_flush_lsn for the corresponding slot till the commit is flushed on subscriber. So, if the subscriber crashed before flushing the commit record, server should send the same transaction again. The same should be true for prepared transaction stuff as well. --=20 With Regards, Amit Kapila.