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.96) (envelope-from ) id 1vR4op-005oRV-1w for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Dec 2025 08:36:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vR4np-001ek7-1e for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Dec 2025 08:35:05 +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.96) (envelope-from ) id 1vR4np-001ejx-0S for pgsql-hackers@lists.postgresql.org; Thu, 04 Dec 2025 08:35:05 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vR4nm-0034HR-2R for pgsql-hackers@postgresql.org; Thu, 04 Dec 2025 08:35:04 +0000 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-b79e7112398so113591766b.3 for ; Thu, 04 Dec 2025 00:35:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1764837296; x=1765442096; darn=postgresql.org; h=message-id:date:content-transfer-encoding:content-id:mime-version :comments:references:in-reply-to:subject:cc:to:from:from:to:cc :subject:date:message-id:reply-to; bh=8yz/rgR5ti/1ZN6Y3MGrUZJkzRnqJ4qlbLMq6oq4MCo=; b=AJfSgOVWlBDsQbgFhuYhPQGi3DJUqkWrfFa8HQFJqQfTO7K108H3u6VKiaKCBUnRSP w++U2dcW9yODmPqxA+O40uMw/WgMB0UjpPNKRTWhacG9B7i/Zb4YXA7JNUQYoFpLdDS9 t5SbBQ983lZqaHdtJMdsIbTa6K/8oJDLKRZQvX8e7CB2z55IDUAx8s/Osdd+fNqKt/hZ Sc+zMMDL24txu1TrfoG1uMP2RPjkMsFE90GQktp/UCXGXGga+PEI4ss+JZPH6QyHZeVs XVZl1oyAiBntTsXNO/uNuKNlEQ8YQ6zBm4SjyRdR0HygYKx7nSincM9p9RJK/VI1xQkx 7EnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764837296; x=1765442096; h=message-id:date:content-transfer-encoding:content-id:mime-version :comments:references:in-reply-to:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8yz/rgR5ti/1ZN6Y3MGrUZJkzRnqJ4qlbLMq6oq4MCo=; b=PUkjTAJQmorCrORC8C3lFrzY6eBl5+x2QwxFLBIbgMO10CcupyL10hEQBCxxDP2pLj PS1wp7Y4qu789pYNyB63ImZwYro5qqjSnj7VBwyBWSWrZc4MSNi76RjJ75KgIsRMucEE PsOtLawjpisFv1TTVi0Dhr78UIp1RQjYAKoxye/jI7fFV0CGjJLypiWOr8nsdmG13s0B nJgyuZ/SgdpuJfhn6K/Cu0i1d/+fRT7MXWc3WI9sPAJDQPtLpC+zCgDWgPm9xEIqmQFG /5gJoIxjXK1qrDR/6LlIe9XjoYpN7BoIpErIhfc2TO9jDHslJakwI38g0ABivnUKMFsR BLgQ== X-Forwarded-Encrypted: i=1; AJvYcCX3bzkFGJ3+KYTB5rU0WFn+85XXovBVwbV0JfEzhY6yshi3zg4usQI90dPA9vSJceUW0PbkkBLmAUqzzQ2d@postgresql.org X-Gm-Message-State: AOJu0YyfPMtPjGLdUK2VIoTXvl1Mf/nZNeiU5hQueykXG0303enIJmEF 7zWCf56pbhpAC+DjMSUus/b/9Ram4uSdwMKL5S/U3ojyt9MabB08DMdi166zJmA1Sxg= X-Gm-Gg: ASbGncvYnOnupCN+5tNtXeP1tOvRTup3SZyJqfLEjPNW70kH8LolZDGt9u/zhJWWsE9 FyE7LwvuEShNRRteeDJXevKSVGGnJEpF4+2omysdJxfpxvUVyxOxDYdJK2mB8r3MuQ47ZpdZ7NS U71NXRgwabtIGjoiTauJDvzyZZ5kxP7hUwgCUwUHWtAioPRyirq9X9Zr2OwOCp0MpT6K2uxVMme 9uTXTQs9xgmhzHfAEhsJOaS+AwDSY/BgqsCykEEOK+KPH38L9Emq+3PuCpWjUyEyqUIBx27vtXN HxxSUmRbhOpd87UOrwtcxRoImPQaXQwIKZE1j2BmtC5d6ZWnUCfbNZTinlCQr2uwlHfM7zz5Ukp hzF5XKRIUX9zbFbEJOV8FkjvMcoEeYleDGj46UfUOe86qlXDr7ZXcFxM2FD3yq49acWwVznpRmc 2larIQhHbRTcicY2mbR2SqMYys X-Google-Smtp-Source: AGHT+IFjUbP7+fU67XHE+k2S8qQ56hHKt70ELGkO305GUyECkBKxku4bvKpyrVyrpbb1gVpXlEt88w== X-Received: by 2002:a17:907:3f20:b0:b73:80de:e6b2 with SMTP id a640c23a62f3a-b79dc51abf8mr578881466b.31.1764837296276; Thu, 04 Dec 2025 00:34:56 -0800 (PST) Received: from localhost (109-81-168-246.rct.o2.cz. [109.81.168.246]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b79f4a53d2fsm67168266b.68.2025.12.04.00.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Dec 2025 00:34:55 -0800 (PST) From: Antonin Houska To: Matthias van de Meent cc: Mihail Nikalayeu , Sergey Sargsyan , alvherre@kurilemu.de, Andres Freund , Michael Paquier , PostgreSQL Hackers , Andrey Borodin , Melanie Plageman Subject: Re: Revisiting {CREATE INDEX, REINDEX} CONCURRENTLY improvements In-reply-to: References: <202505181556.3n6oiowvntyr@alvherre.pgsql> <5784.1764580169@localhost> Comments: In-reply-to Matthias van de Meent message dated "Tue, 02 Dec 2025 11:51:06 +0100." X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.3 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <5292.1764837294.1@localhost> Content-Transfer-Encoding: quoted-printable Date: Thu, 04 Dec 2025 09:34:54 +0100 Message-ID: <5293.1764837294@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Matthias van de Meent wrote: > On Mon, 1 Dec 2025 at 10:09, Antonin Houska wrote: > > > > Matthias van de Meent wrote: > > > > > I'm a bit worried, though, that LR may lose updates due to commit > > > order differences between WAL and PGPROC. I don't know how that's > > > handled in logical decoding, and can't find much literature about it > > > in the repo either. > > > > Can you please give me an example of this problem? I understand that t= wo > > transactions do this > > > > T1: RecordTransactionCommit() > > T2: RecordTransactionCommit() > > T2: ProcArrayEndTransaction() > > T1: ProcArrayEndTransaction() > > > > but I'm failing to imagine this if both transactions are trying to upd= ate the > > same row. > = > Correct, it doesn't have anything to do with two transactions updating > the same row; but instead the same transaction getting applied twice; > related to issues described in (among others) [0]: > Logical replication applies transactions in WAL commit order, but > (normal) snapshots on the primary use the transaction's persistence > requirements (and procarray lock acquisition) as commit order. > = > This can cause the snapshot to see T2 as committed before T1, whilst > logical replication will apply transactions in T1 -> T2 order. This > can break the exactly-once expectations of commits, because a normal > snapshot taken between T2 and T1 on the primary (i.e., T2 is > considered committed, but T1 not) will have T2 already applied. LR > would have to apply changes of T1, which also implies it'd eventually > get to T2's commit and apply that too. Alternatively, it'd skip past > T2 because that's already present in the snapshot, and lose the > changes that were committed with T1. ISTM that what you consider a problem is copying the table using PGPROC-ba= sed snapshot and applying logically decoded commits to the result - is that wh= at you mean? In fact, LR (and also REPACK) uses snapshots generated by the logical deco= ding system. The information on running/committed transactions is based here on replaying WAL, not on PGPROC. Thus if the snapshot sees T2 already applied= , it means that the T2's COMMIT record was already decoded, and therefore no da= ta change of that transaction should be passed to the output plugin (and consequently applied to the new table). -- = Antonin Houska Web: https://www.cybertec-postgresql.com