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 1uqWwu-007ySI-PV for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Aug 2025 13:09:26 +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 1uqWwu-009Sf2-8K for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Aug 2025 13:09:24 +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.94.2) (envelope-from ) id 1uqWwt-009Seu-UC for pgsql-hackers@lists.postgresql.org; Mon, 25 Aug 2025 13:09:24 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uqWwr-001lTP-2x for pgsql-hackers@lists.postgresql.org; Mon, 25 Aug 2025 13:09:24 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-afcb78f5df4so741250466b.1 for ; Mon, 25 Aug 2025 06:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1756127360; x=1756732160; darn=lists.postgresql.org; h=message-id:date:content-transfer-encoding:mime-version:comments :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LA541hXk0NDYMk5+8Bu/mdMfB24iHG8NUEQBcBLqSdE=; b=oAE6vFEXt5X8jzp8dY1yjy9u0Tje4kYIdAlldz0lWw1btGxYxbeHf1Yie3ZNQ/Z4MM dyc6Z6HeiBEC3OU6fBxwQKHOIfkcnpXawKN84X6OkfItZEM0MqHRYBtGlkJyEEHdzxOW svWajFGOrQW7RnD5mMsd2Azi8LWyxtXmkRyOkle6K38ke8TQWLkn/PdzUWtNiEEewQO5 mp4FYS/zNVaTWIs1C99yGy4ksl97lWy2xH6TZfnhbOg0JwKswbrbV6ygLIfe0LyHfnr9 qIlQ0y/5ElHWUb5WyICZAnF69xqlHbCib2/xxv+iwZLtcIsqh1vdMQnlySSLRBJTiIFo 7Fbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756127360; x=1756732160; h=message-id:date:content-transfer-encoding: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=LA541hXk0NDYMk5+8Bu/mdMfB24iHG8NUEQBcBLqSdE=; b=PPO+lfaiRSdh+hFdkzh1aBc/pVkGuBHkKlvBdKdwCJ4WzQJhJatUsIZxNY3EnWWTM3 cEapTJbhuv6cgLw/2I0aTcHxAgbY3SbgDWs+gpwWLq4drj5+EctAgRvAwXUiJawGkdDo hElzdbQ/nracYX93aKC4qvsISQJsx9oS4IoC4yMqciT6lWo9zHbsTTbyA+DGnoN9GoO0 Cqld0xdaIQbDZ1jXsh3L5STbEqki3/z7nz/XWUwM/b9xS8ax6RT5gTNSCLuacMai+yjR Hxz/k5smUTeJ+RJ58kLzr+XQm2l90Fv3b846pCZluaBXWkz/F98oqltpuokS/lt1NTGI kmyg== X-Forwarded-Encrypted: i=1; AJvYcCVQrr7qwGrFIkmxS4TZ9HCp4XycjzoH7iMBtsZFgaZ+e5FfyvwuKgkcEfaEUvwTXu15kiWZ32hEiIvqWhcZ@lists.postgresql.org X-Gm-Message-State: AOJu0YxX1jUshgTRbt2ycbOyeo6xC/e3ExULHcnttRY1G55gRZOn5ENU XF3UMjqS0QRBlfDa7tDgdm0c2PzaDH3YKwVKpurVhIQ3aY3giFANJ9mv5D1wQJw4JPg= X-Gm-Gg: ASbGnctLLnzi2D8JB+NECV6iVdR8wHGJNHElRh4+wpcMh6yuztb04dG84C02kXk7QJn Bjjlajhru/Rv4lAqb1g4VEWrOUSiZvIWtGUoSMaLhv3bgqY9bADgWGCnH1D9W4RIA4Q7Y6VA8WV aLrt+X0xzcgap0Uz62O0t93NjjrjfkJqhw6Szv1EJf7B0WFEwmEwtS6y/wtKh62NqJnkdGPQehN Q3FzDFGemXEIa3ApnydWvclUj+VLpBPDTm8yeFO0b5UKW1BGCA3Eckch5xXfGJZ5ar+m6N/07in c3CoTRVMSO2+ZmDMzsCj273CvWJcQIfpcUjgmAwvsqVzzTKJvvgb4a4awsM/I/QDUJaiJO/G5tB 3g4FMtMlzXVpCHNNFj78zVRkUoG8YkwYg1xH5 X-Google-Smtp-Source: AGHT+IFETGrpgBLv4kzhdc6ky4hfFlPqq0r1niWaFuYVBDHbvVdNpE9cuTTU2WEc/ef4nmLdHByGzg== X-Received: by 2002:a17:906:6a0f:b0:afa:2672:8c49 with SMTP id a640c23a62f3a-afe28fd037amr1031980766b.18.1756127359681; Mon, 25 Aug 2025 06:09:19 -0700 (PDT) Received: from localhost (109-81-168-144.rct.o2.cz. [109.81.168.144]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-afe48e897d0sm559137466b.16.2025.08.25.06.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Aug 2025 06:09:19 -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> Comments: In-reply-to Mihail Nikalayeu message dated "Sun, 24 Aug 2025 18:52: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=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 25 Aug 2025 15:09:18 +0200 Message-ID: <9536.1756127358@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Mihail Nikalayeu wrote: > I was looking into catalog-related logical decoding features, and it > seems like they are clearly overkill for the repack case. > We don't need CID tracking or even a snapshot for each commit if we=E2=80= =99re > okay with passing xmin/xmax as arguments. I assume you are concerned with the patch part 0005 of the v12 patch ("Preserve visibility information of the concurrent data changes."), aren't you? > What do you think about the following approach for replaying: > * use the extracted XID as the value for xmin/xmax. > * use SnapshotSelf to find the tuple for update/delete operations. >=20 > SnapshotSelf seems like a good fit here: > * it sees the last "existing" version. > * any XID set as xmin/xmax in the repacked version is already > committed - so each update/insert is effectively "committed" once > written. > * it works with multiple updates of the same tuple within a single > transaction - SnapshotSelf sees the last version. > * all updates are ordered and replayed sequentially - so the last > version is always the one we want. >=20 > If I'm not missing anything, this looks like something worth including > in the patch set. > If so, I can try implementing a test version. Not sure I understand in all details, but I don't think SnapshotSelf is 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. One particular problem I imagine is replaying an UPDATE to a row that some later transaction will eventually delete, but the transaction that ran the UPDATE obviously had to see it. When looking for the old version during the replay, HeapTupleSatisfiesMVCC() will find the old version as long as we pa= ss the correct snapshot to it. 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 transact= ion may already have committed. In such a case, HeapTupleSatisfiesSelf() will conclude the old version invisible and the we'll fail to replay the UPDATE. --=20 Antonin Houska Web: https://www.cybertec-postgresql.com