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 1vOzoB-00GoBO-1M for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Nov 2025 14:50:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vOzo9-00BuL0-36 for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Nov 2025 14:50:50 +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 1vOzo9-00BuKs-29 for pgsql-hackers@lists.postgresql.org; Fri, 28 Nov 2025 14:50:49 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vOzo7-001xYh-22 for pgsql-hackers@postgresql.org; Fri, 28 Nov 2025 14:50:49 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-594285c6509so2333347e87.0 for ; Fri, 28 Nov 2025 06:50:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764341446; x=1764946246; darn=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=A0uIM+xtZiiilnLZlT/xgsSGKPOKU5X9b93zDZy3d4Q=; b=iMweoaZ7EX0AjMreAjKTZXd/OPVHmJtxUv1PKY2u5s2stom2k391m/tfGxtjA7xT/G a89Dx1VLgiYBSNtxH0px/yMS7hQCURYmw9pr7CR6DbPo6mahNCWyTth5mbO8hh3OyZV1 sd+713+uDwDn3fn7PKPC80crcXg8cdOn//RxCxhE6C2JYVmSuM8JaihHSn3FH+2J4ADp 9yvkmaqgyUrNRmOhcD8UG2q5ffscqJEQRerT6zeAn5+84gwuKpt5b5nkrLrXliA8GYs9 Rxsd8vFg6ncXp1dnE2jtHV+JoGI/pfiuMZ0VzE+GfpX1Muvve8uVIsG2UMKC3ORmbM4f g4gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764341446; x=1764946246; h=content-transfer-encoding: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=A0uIM+xtZiiilnLZlT/xgsSGKPOKU5X9b93zDZy3d4Q=; b=gh5f+2F4UDOHQZtmGX0Cd9xGomfBAp451aF37T31nAn3cVEMN1JJUvMT7eDNew9+Pc NTrYQEXeC/4VldEUCID7Tkz0ZbbaDMngJowTjVe+0WOHGIXdSlCjoayuKFs/UPlvtpYd ld2Wuk15RO52vRWcomN9rqynIsZ22hTjCCAhwl+WF4BS8J1+HgmiAWrzQIgSDB2YkHug V3eDMha2aL5EEZgWP67VJv7uS0Dn70EoGlOsyrJHd1cuCqKxWQlRCSoWa3x2xcogy0Xg c0T6t6B4roYUWikaGBgSDcyAcyqUNcWbSgXoemD+SqUyLL/ChkM+lvPKkXpTi9f1B5qp H9mA== X-Forwarded-Encrypted: i=1; AJvYcCU/SuccDethuCfQ7w/Hu3YHrZt9yRtejE2gH9AAspY2w8vxoRhJBhqtPTAABFfg0igcJIBtu/jahFtt7R0P@postgresql.org X-Gm-Message-State: AOJu0YwW8xcOhLXCczkjoNzX3LKWzG8b9Wo3jRrEU6iVEVmt5FVc+XH6 tpISvf22lDQ1ak8vLkWU42eHUz/l8elGzlgIFTfXEjpKPFdotcZj2rwFaKQd2giTuL7x5OAIfW2 KULkd7+nWa74rAj39grXr8x05KSCnLI0= X-Gm-Gg: ASbGncsksWOrpIaVVL5xGOoGszDLBmhyCS4yCh0pdTVmZI5xCnqV7jYavL7TRZJHKdb OEE/9eMQXXlwfUKcGNiURWB4Ihhm13Fu5brw1tHoxp/Rc6wwmNKYgRymA8Z6/gH47IkVh1Graaz 37lXxj2DVE/7tCt1c196lGL3ERnzM8rHHrJkpIpa1IqeLmec2a0iCvguOeplPYXidyuJGCQNEp2 6W1PX44bSE3sJoE9i3k/hW/X6ATY/a+xk6elwaiSUgzEfthYf1duLnOLCQlRFVRPkm+sGQzlFGM iLLB8gU= X-Google-Smtp-Source: AGHT+IFBKMNmMEiEKD8F2UMGNiK51EvdGVn5+hLXt04f32I6vUon/P+T0kO+yPsm9zPU1BVWW3JHtJg55i3XVbveVpU= X-Received: by 2002:a05:6512:39ca:b0:595:80d2:cfee with SMTP id 2adb3069b0e04-596a3e6ba4dmr10751023e87.0.1764341445371; Fri, 28 Nov 2025 06:50:45 -0800 (PST) MIME-Version: 1.0 References: <202505181556.3n6oiowvntyr@alvherre.pgsql> In-Reply-To: From: Mihail Nikalayeu Date: Fri, 28 Nov 2025 15:50:00 +0100 X-Gm-Features: AWmQ_bmeQIfKMgciBeg9n0b8aegyXje9fLEOwrNJ8m_0MmTFeuJ2qDPmrkVYRaY Message-ID: Subject: Re: Revisiting {CREATE INDEX, REINDEX} CONCURRENTLY improvements To: Matthias van de Meent Cc: Sergey Sargsyan , =?UTF-8?Q?=C3=81lvaro_Herrera?= , Andres Freund , Michael Paquier , PostgreSQL Hackers , Andrey Borodin , Melanie Plageman 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 Hello! On Thu, Nov 27, 2025 at 9:07=E2=80=AFPM Matthias van de Meent wrote: > While it might not break, and might not hold back other tables' > visibility horizons, it'll still hold back pruning on the table we're > acting on, and that's likely one which already had bloat issues if > you're running RIC (or REPACK). Yes, a good point about REPACK, agreed. BTW, what is about using the same reset snapshot technique for REPACK also? I thought it is impossible, but what if we: * while reading the heap we "remember" our current page position into shared memory * preserve all xmin/max/cid into newly created repacked table (we need it for MVCC-safe approach anyway) * in logical decoding layer - we check TID of our tuple and looking at "current page" we may correctly decide what to do with at apply phase: - if it in "non-yet read pages" - ignore (we will read it later) - but signal scan to ensure it will reset snapshot before that page (reset_before =3D min(reset_before, tid)) - if it in "already read pages" - remember the apply operation (with exact target xmin/xmax and resulting xmin/xmax) Before switching table - use the same "limit_xmin" logic to wait for other transactions the same way CIC does. It may involve some tricky locking, maybe I missed some cases, but it feels like it is possible to do it correctly by combining information of scan state and xmin/xmax/tid/etc... PS. > PS. When I checked the code you linked to on that thread, I noticed > there is a stale pointer dereference issue in > GetPinnedOldestNonRemovableTransactionId, where it pulls data from a > hash table entry that could've been released by that point. Thanks!