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 1vQNyj-006b27-31 for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Dec 2025 10:51:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vQNyi-007I03-2w for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Dec 2025 10:51:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQNyi-007Hzu-1w for pgsql-hackers@lists.postgresql.org; Tue, 02 Dec 2025 10:51:28 +0000 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vQNyd-002jOR-14 for pgsql-hackers@postgresql.org; Tue, 02 Dec 2025 10:51:28 +0000 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-37bac34346dso1355521fa.2 for ; Tue, 02 Dec 2025 02:51:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764672682; x=1765277482; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Lm9J5R7QHE62o788rOM6GMIq8ONdimu8FRIhAvZaHWI=; b=k9H5Ov/i6PwNfk2OVWL0/q9bK8zZdth6QX16ea7uHJBELZ3Q/2ZE0QHV7nJxHFvBwo DQZ/lRTamDMyYZhvcVNw7fimFav0c7Fe4LKHyUn/ImGys12FU+45RfJYJnuqQSOl7nlc Z9GV1WRFJ2KQrUYRZp4Mq13qmQybMB/X36im08eB2oy6RmBYuLVLXUBQRxC4qMlknbLB wUOEPSp8y2U4InIhoEKnyA7eFd54kxDOp3zqLGo4pEbbB/aPVYs5r1QeBfNNcd465tri ansJBUjd6+WvuMpY4OprPZpItb2lx8ZkSF5S56b4Vwd9Od6prRlZp0GG4tDlC7riLJIB 2ndw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764672682; x=1765277482; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Lm9J5R7QHE62o788rOM6GMIq8ONdimu8FRIhAvZaHWI=; b=qcIYmZbj+YNCCYohs1uia3zCoMsMoVIv9Zaz3NGgEBPQYcagIT4WucSGOumalS7nRw Rgyt8neCn5yJqXOpeFYQYA/U2lm28Q4AQ4HTV8hG1xQXm74grbl5ZjAtCjchCOiZ8fus YSqbIcux1xnPBnro4pSeDNnQ+CvufCCeaW6MM6G/uZZeXd+VHVMG6ySC31RL9Bzp2D5c 1r8J3SbtUknqZDar8Cry0z5OWZy7JlRZz3gHP1WXwS3T8u/Kkqq8AtNFMeL12EKpK9cF I9bGzw4serc1TiitGw9mgn/CdgTKJkkvyDHKBUscdF5Foy+BWJ4azMAmeZ6tq/9kCz4Z Vvyw== X-Forwarded-Encrypted: i=1; AJvYcCUfz9eI2R8jsTQHSvo/eLrzcfYZWt7PxHBpDM9hDGo8CYVEk5+PMqKK6CUiD1jtQ2a3IJifEi8VE73d+GHq@postgresql.org X-Gm-Message-State: AOJu0YxlVSAnz1/Ku9XBBRhqzCu/TpqsPIu3z3jxX7MukNII5Nh3om7U f9++s2Jcdu4IJ9S9S4uxrUzkzVdZj9irUy8vhE1AnHF3coQUEhT1JMV7SMCVjbK0CpFMqatyNM0 +6bZcqfDCrOn5tBugOpyuRPMZnbpRPbY= X-Gm-Gg: ASbGncsEvP6ZdLfS1OFPqVyMBboEwe5Aj70CkXB3+4cEwKu8kx+PEqOQlfMf9JapCg8 yoi9X80UWTmFbS9GSp6fPDlSYKxfDiYJfQp6m6lDNU+aiK5sqZwdFYcwnnjHka4adJHzRa6r7VX mz6bf0Q9+WD5sUVlAcu/0XKp3ISJJLlxhOnfbeWsnvtU/9Jhj24hd2lymTN925Xtl14Gq1T+gv7 bYZeaHmFonixA0RudqH65g+hqhk8jixfhPjkqZdwKF+e+OpF0yjE1Pbu+q38whgsbA/BROydM8A UjM7Gsugi8rfxZSMzx8zM/fzn0aOMquMUsEik2Kc2zRpJQ6fCxbOW7GnsEpPp4kpnk7B X-Google-Smtp-Source: AGHT+IFtfjr5AblKrHsDDobspJ32d5xhzmfSUu4IV+XmN+uA4+E++bZyFv9TrFCywEwJBRrGuEEUvHUN3M8zH6L81bc= X-Received: by 2002:a05:651c:4416:10b0:37b:aac1:282e with SMTP id 38308e7fff4ca-37cd9287c95mr111149541fa.28.1764672682095; Tue, 02 Dec 2025 02:51:22 -0800 (PST) MIME-Version: 1.0 References: <202505181556.3n6oiowvntyr@alvherre.pgsql> <5784.1764580169@localhost> In-Reply-To: <5784.1764580169@localhost> From: Matthias van de Meent Date: Tue, 2 Dec 2025 11:51:06 +0100 X-Gm-Features: AWmQ_blUm-QP9Du9gJYKxJGcem48HY0uT-FtiYbtHLsl_pjCFLpVW4GPuaJtamU Message-ID: Subject: Re: Revisiting {CREATE INDEX, REINDEX} CONCURRENTLY improvements To: Antonin Houska Cc: Mihail Nikalayeu , Sergey Sargsyan , alvherre@kurilemu.de, Andres Freund , Michael Paquier , PostgreSQL Hackers , Andrey Borodin , Melanie Plageman Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 two > transactions do this > > T1: RecordTransactionCommit() > T2: RecordTransactionCommit() > T2: ProcArrayEndTransaction() > T1: ProcArrayEndTransaction() > > but I'm failing to imagine this if both transactions are trying to update 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. I can't think of an ordering that applies all changes correctly without either filtering which transactions to include in LR apply steps, or LR's sync scan snapshots being different from normal snapshots on the primary. Kind regards, Matthias van de Meent Databricks (https://www.databricks.com) [0] https://jepsen.io/analyses/amazon-rds-for-postgresql-17.4