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 1up9gt-0001wa-2A for pgsql-hackers@arkaria.postgresql.org; Thu, 21 Aug 2025 18:07:12 +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 1up9gs-000k7V-5T for pgsql-hackers@arkaria.postgresql.org; Thu, 21 Aug 2025 18:07:10 +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 1up9gr-000k7M-QE for pgsql-hackers@lists.postgresql.org; Thu, 21 Aug 2025 18:07:10 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1up9gp-0013mz-14 for pgsql-hackers@lists.postgresql.org; Thu, 21 Aug 2025 18:07:08 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-61a8b640e34so2631039a12.1 for ; Thu, 21 Aug 2025 11:07:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1755799625; x=1756404425; 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=aGJWPzWapR3OgMXFsxEwcheEpEcph48CmRLR5AVMLzI=; b=AiFNAipO0YmcFrpKsuRuNqhgaAiJsg2OqBKGMCJ4oW5ZUKEPyq1GxfBz2Cf0+FDg93 e3/P8GBfaPIPxZ64MHHNYpFL0NGf4aEGuK7e7+4mzQej94zD9mJqKr1xCOU5XXgtws6J R6M553OzSCatb6mFooJBxdJZD+hiYRIu9vlzmzLGazlxYfLQKZ9wRNSoX+3kjnNbggOq Rr84JeaoiOa2RPNMZzu92Qe1yivSwBhWBkH20zzI/5MLmxqRHr5IPBFfE/57UfJQo0QT NusSD1u6q41Vxp5n60a/K7qcV0B2wYlbLCJVrO/dYxPGxvWLr6pkoODpuuJmYowrNQQw AY+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755799625; x=1756404425; 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=aGJWPzWapR3OgMXFsxEwcheEpEcph48CmRLR5AVMLzI=; b=v2mtWZCA5y2kns9wm4vcNowfafzIt0eMfPjDBGAt1xdZuKffULr1oBivp7xEmQq7t3 tKr9ed/Lq1w7x+jeR/vR7xizj/BWoyIKKsJ03PyGIxHqO3sfx+79KA845n108pCBFUXo tZVH3+6shiH8VqIoji74yUjggX0zhLdov4rWzCn0Jo0IJ5vsXhQhgI/ofJwzXcBwIjVH ymyHLjsoMHmSn54mNf8DhlEa6ofPN+VcBwdSPIxNR5qmSuYebDXzQ708hpAqq1EXJQpp SG8RwCzrNybiqhBzEqNq65vNmvU7GivMREk8F6MW1MynfwZd7tst73iRHLeTSfhRav0T D31Q== X-Forwarded-Encrypted: i=1; AJvYcCWPPFca7FapYF/YFp0ODjzfk7JasuI863CDHFBDS/tl6hsBlXbc1hABJSFiWObLc9muz6jOJkBeYKoAWdLz@lists.postgresql.org X-Gm-Message-State: AOJu0YwcR6PlgZTOdAbXALe0fbb9z6UCMLATltnDDzCjK/vTBtuOeguw 8x2LH4847aRYm9lPFo3T/xVTCUi4JegyxWGmrCf784OUfp9/gXKjjJtnNvNw+48E0ek= X-Gm-Gg: ASbGncsL2CO8ZcKrCSSv/XnyoshAOyHj/WafHdYUO1E4O4SMJ2stDlwUYuxHhHeTuWf qBhXZqbChTLn2Y5t6cSSthAp6B2R30OBHsOqDN9V8iF1l/IxncMe/i6ygfC2rnO9V+o79uXPt/8 sXbIqhlKn9o2Sqq6U0JukuyrWGQA1/zIgwNx9m67oYGsWF25K9JrRoKnATiomEGsMsHa3wVZ530 t3UrDVaRdRN8USCg1aViO3r4XDnfTxGzEHoPG2SooM/DxfXjPoXwFj6fY+7t2xEoWFhlchFVZ4V s170knfoSmwASAh2r0ksEGL3QOLu44BHhV9wX+RbixFKKlcsHXGlCFh77XT/hPOeHhzAj7eYX6a 8GnrfGpdKrUlsI6AY5u7S2m7ug5qmL7/lozES X-Google-Smtp-Source: AGHT+IF41PjsF0fdSBkDCr9YRP5H9NadVoQSFZj7DZYfsk5jbem4QoE7OMnAVnGDqmKJ435UOPZ2aA== X-Received: by 2002:a17:907:940e:b0:af9:a162:7fa8 with SMTP id a640c23a62f3a-afe2965b632mr4190466b.50.1755799625337; Thu, 21 Aug 2025 11:07:05 -0700 (PDT) Received: from localhost (109-81-168-144.rct.o2.cz. [109.81.168.144]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-afded2bc305sm425550366b.18.2025.08.21.11.07.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Aug 2025 11:07:05 -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> Comments: In-reply-to Mihail Nikalayeu message dated "Thu, 21 Aug 2025 01:44:00 +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: <40728.1755799624.1@localhost> Content-Transfer-Encoding: quoted-printable Date: Thu, 21 Aug 2025 20:07:04 +0200 Message-ID: <40729.1755799624@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Mihail Nikalayeu wrote: > Also, I think I found an issue (or lost something during rebase): we > must preserve xmin,cmin during initial copy > to make sure that data is going to be visible by snapshots of > concurrent changes later: > = > static void > reform_and_rewrite_tuple(......) > ..... > /*It is also crucial to stamp the new record with the exact same > xid and cid, > * because the tuple must be visible to the snapshot of the > applied concurrent > * change later. > */ > CommandId cid =3D HeapTupleHeaderGetRawCommandId(tuple->t_dat= a); > TransactionId xid =3D HeapTupleHeaderGetXmin(tuple->t_data); > = > heap_insert(NewHeap, copiedTuple, xid, cid, HEAP_INSERT_NO_LOGICAL= , NULL); When posting version 12 of the patch [1] I raised a concern that the the M= VCC safety is too expensive when it comes to logical decoding. Therefore, I abandoned the concept for now, and v13 [2] uses plain heap_insert(). Once = we implement the MVCC safety, we simply rewrite the tuple like v12 did - that= 's the simplest way to preserve fields like xmin, cmin, ... [1] https://www.postgresql.org/message-id/178741.1743514291%40localhost [2] https://www.postgresql.org/message-id/97795.1744363522%40localhost -- = Antonin Houska Web: https://www.cybertec-postgresql.com