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 1uqZKw-008hrC-2D for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Aug 2025 15:42:23 +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 1uqZKu-00AlJt-4a for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Aug 2025 15:42:20 +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.94.2) (envelope-from ) id 1uqZKt-00AlJk-Pn for pgsql-hackers@lists.postgresql.org; Mon, 25 Aug 2025 15:42:20 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uqZKr-001gM8-1h for pgsql-hackers@lists.postgresql.org; Mon, 25 Aug 2025 15:42:19 +0000 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-61c325a4d83so3125856a12.0 for ; Mon, 25 Aug 2025 08:42:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1756136537; x=1756741337; darn=lists.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=u/QD8H1j9ny0CGWMPooqFCShnRUvrkR1bewFBXIQAh4=; b=IVivyce9iFjm64HqrcUmSSHgiX0ogiS3OCcNsflLcqn0oo56QuuE3ZOTsgUakdi0ks FZpFhnokW0CM1fgln3MNx+ZlSM118xKHbMnG7g9O78onn9BwhzwdjVnaQ+vCQGSXYspF 9ELnBrcfOfbSlPWmFHfWaJXVoI8Mmfa5IXVXdFIbXYAf8eq/crIgsYjPfNMtqrJEE7Rp eJy/8ro+TN4QxexD/wgR2wrImZvT7nwaeZKYs4Ckq2FYp0EKetfyMCfhccMVhGldAP4G oE3DVJRUcvV84AIrUgwTTbCZnNlfTDLLzsfI/sqSs3tqPvWGWq1vlpm7hpnDZPGEinHp WWEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756136537; x=1756741337; h=message-id:date:content-transfer-encoding:content-id:mime-version :comments:references:in-reply-to:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=u/QD8H1j9ny0CGWMPooqFCShnRUvrkR1bewFBXIQAh4=; b=Z+eoZbr83ocIVjKZ9oNSuUAOhrI7XN3dWFvjTwaO2glfJzZvuiekecSW1NrCETm/rb YwlVqj8So2osWHd3A+rEM+bq/Yqd0yTOdQw8PwbdEoaY9Nlw1LIfzSVsGAAWAtmaf/D+ t8wzFO9LDGhEswzp3F8iqtasmQHitv+1zaiTjr/s5o3nTfnIxL0HVb5yXKW2IkOHvdbz bA4WlG76HR+YU9skUx7YUizmqAWpnx9rdFx3mlAx1COQojMSHuhV3AVour+TMDz7y9Wa GZuT4/5lD30/P2jQFkl/lbs9D9N8POS08Fi/CGeCtTe4gvkOlzuHEv0es8pAbRhJUjAp AZ8w== X-Forwarded-Encrypted: i=1; AJvYcCUsoG6wkpXOtYqs74O/148tCRbxKi8ghjN3sVGKDLvn+oU8BDQpHtSoiidj3iA27lFc39K593ltkAGPRM9A@lists.postgresql.org X-Gm-Message-State: AOJu0Ywhr6x5z81m/7IIvdC882lWwMnCc3Ca+eUxCdxNKMaZZMPW+odh Lz5GuVi0xK8KM6O2HxYgAqekLjrhZpUKCZOFD70ybNEnhh6ulEhMxOypsFHdtbMpgiU= X-Gm-Gg: ASbGncs9kpztPxZQd4QPPB3A0ZLAw+2pJHiYGdw9jaoJu9LhNO+8ObdtGyahdRHBKI5 ulcGZYwPckrNgcRQwZcieP6HXC3xAswOML+yBgBRfFzNxS5tgGQLXFVZUf5JHZtuLgkaeR4ic4g nWzS9ShqA97XdYtsE29v+r/3VnaOZMWAsB3JXUGI0ykDmep1Tfxs2bCnwtgmLJ0dEK5b/TLzY5u 1bFuNYiIGjj9K7YZo7Ayv9vqs+mCDUDx+wtodCifKlBCX8vgq3LyUcRC1vigqKB8u8Tti4RC0xr ++1EUehM6Sw3jyc87pDjUgdo5cfEjkVbwzYNwhLjHfOgQq3/Nph/n/b+PIgi6dFnrP3ZeVNea+u +039gsEBMxHSAaY05qQU0IHk+jH55iVvDDcTL2whwyQClf3w= X-Google-Smtp-Source: AGHT+IFvCNpXJxUwateoR2nNjkySEpKz6y+Dlxq/9U9+ZDucWAeje1T5a7uVHOHxCCMIRKenNyHPgA== X-Received: by 2002:a05:6402:3552:b0:61c:5b92:e316 with SMTP id 4fb4d7f45d1cf-61c5b92e3b5mr3906320a12.4.1756136536651; Mon, 25 Aug 2025 08:42:16 -0700 (PDT) Received: from localhost (109-81-168-144.rct.o2.cz. [109.81.168.144]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-61c3119f85esm5079820a12.10.2025.08.25.08.42.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Aug 2025 08:42:16 -0700 (PDT) From: Antonin Houska To: Mihail Nikalayeu cc: Alvaro Herrera , Fujii Masao , Robert Treat , Pg Hackers Subject: Re: Adding REPACK [concurrently] In-reply-to: References: <202508091333.qvgvo7ikuezm@alvherre.pgsql> <40729.1755799624@localhost> <9536.1756127358@localhost> Comments: In-reply-to Mihail Nikalayeu message dated "Mon, 25 Aug 2025 16:15:16 +0200." 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: <21930.1756136535.1@localhost> Content-Transfer-Encoding: quoted-printable Date: Mon, 25 Aug 2025 17:42:15 +0200 Message-ID: <21931.1756136535@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Mihail Nikalayeu wrote: > > Not sure I understand in all details, but I don't think SnapshotSelf i= s the > > correct snapshot. Note that HeapTupleSatisfiesSelf() does not use its > > 'snapshot' argument at all. Instead, it considers the set of running > > transactions as it is at the time the function is called. > = > Yes, and it is almost the same behavior when a typical MVCC snapshot > encounters a tuple created by its own transaction. > = > So, how it works in the non MVCC-safe case (current patch behaviour): > = > 1) we have a whole initial table snapshot with all the xmin =3D repack X= ID > 2) appling transaction sees ALL the self-alive (no xmax) tuples in it > because all tuples created\deleted by transaction itself > 3) each update/delete during the replay selects the last existing > tuple version, updates it xmax and inserts a new one > 4) so, there is no any real MVCC involved - just find the latest > version and create a new version > 5) and it works correctly because all ordering issues were resolved by > locking mechanisms on the original table or by reordering buffer ok > How it maps to MVCC-safe case (SnapshotSelf): > = > 1) we have a whole initial table snapshot with all xmin copied from > the original table. All such xmin are committed. > 2) appling transaction sees ALL the self-alive (no xmax) tuple in it > because its xmin\xmax is committed and SnapshotSelf is happy with it How does HeapTupleSatisfiesSelf() recognize the status of any XID w/o usin= g a snapshot? Do you mean by checking the commit log (TransactionIdDidCommit) = ? > 3) each update/delete during the replay selects the last existing > tuple version, updates it xmax=3Doriginal xid and inserts a new one > keeping with xmin=3Dorignal xid > 4) --//-- > 5) --//-- > > However, at the time we're replaying the UPDATE in the new table, the = tuple > > may have been already deleted from the old table, and the deleting tra= nsaction > > may already have committed. In such a case, HeapTupleSatisfiesSelf() w= ill > > conclude the old version invisible and the we'll fail to replay the UP= DATE. > = > No, it will see it - because its xmax will be empty in the repacked > version of the table. You're right, it'll be empty in the new table. -- = Antonin Houska Web: https://www.cybertec-postgresql.com