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 1urYft-008PKc-6Q for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Aug 2025 09:12:06 +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 1urYfr-0021SC-HT for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Aug 2025 09:12:04 +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 1urYfr-0021QS-7l for pgsql-hackers@lists.postgresql.org; Thu, 28 Aug 2025 09:12:03 +0000 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1urYfp-002AF4-1U for pgsql-hackers@lists.postgresql.org; Thu, 28 Aug 2025 09:12:02 +0000 Received: by mail-qt1-x829.google.com with SMTP id d75a77b69052e-4b2cf656e4fso7188741cf.0 for ; Thu, 28 Aug 2025 02:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756372320; x=1756977120; darn=lists.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=Y8e8Jh7kE2gc7iMMKHvaIMtIE6HlQ5iUQz3czYfRgL8=; b=AoR9d/AuUl/HN7pUym9E9ybeeCP9h5A/AXV1krqu95gsWafB6ylqhrhsqPk50iYGaF 5/TwygvIg+p7z4oLQE9f468NyRBEaAEbhbBDb69JdLNrVQh4CfV7qlgDAaqOzVs9Ag2C XJsZ+J5sMDVhOwba2VOnsIHNuCLaWkEHrWOc9Te53h6mIhi64Ggo9whAGIlqjYhQGqWM SlTuIrZOlKS7XZUiAQ+hDpUsMtCFMe5lKqMLSU1gTAKHntRppsbAzuz6sI2Rw/rJXe6J uRF+jQhEh2SLGIEBWIO0TfzJsDdQBjwjlsTyvRP983YBOfKhYF577ZSrP3Lx6o4ky5lP cJOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756372320; x=1756977120; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Y8e8Jh7kE2gc7iMMKHvaIMtIE6HlQ5iUQz3czYfRgL8=; b=uOaAvEXn5Cuzb5tBDNmUv0G93xTqvx/DEgZBD7PTjtTO2JhuUGBiTw3dRhuXoBFa0U mVTViLUccsnsE2N8jkAwy+fCOMKfT1deHeMNQoPnEAS5IveZYht5V6Uboa4a52bHSrc/ WEs3NsGKRLJAUyTlUO3Qv3Ove9Oa/Llb2w5vsJ/qTlGwU+ibc0SpSIxONGr60KVicO43 8VwNwFt52+2ylkywwTbBRvVxmzvSlCbJnZnMv+Soe+uqOyyDRRXgSpN/wHNTAt0P2S3a NJqL1RqXjveaVKbdG+jtgG5KwJ5rVBIDuBIOvEk7uLF4tnmG++P+Nk+DewGqtRJcpt88 n1Cw== X-Forwarded-Encrypted: i=1; AJvYcCV4y8Nlg4d7BpfY6DCDFjZU8ax8d4DZYJxJoYjALPn9zuTWn7F5uUfNkd6+KxRa+CRcz3vqtsTyx8992cyT@lists.postgresql.org X-Gm-Message-State: AOJu0YxEHpxzPV90dmT424A2dw1S2q8tjk0UhGVde477TXITzAaUXH3x H69cjlRaLnK2sfnGi3CbsGEKfffjXTEuUb7lhgEvP72VsuvlmY7L5z+c+05cZw8UES7E2O+vmmm v9il/Q9A4erVNho64ZShC8IryEMx86JU= X-Gm-Gg: ASbGncuZ9Woa1LxN6AWa2XpzXiUOf5NHkGXlCSFaW96CFHLRcOP2mHIfz36yfaFPx6u MIduXtDSsxh7C1dCnA4WuwfLGiXukLyeDwQe8viMAfVzJZsHczXKviafG/FxAnsZo1RaaA0eJ8p oSRfhc3HPGQ1i0VSnqs6NtMLhfHRLhjfNWNgrB75cHrk/jkvjE7cJekoRG83caj68gNLoS3Paxd kGOiLQ8XamtkwjneOmFIbKVZODgrEkoDl1wmasvNEMTPI0cfg== X-Google-Smtp-Source: AGHT+IGnUtsyaMsV8YxAgEbinQC2dBP/dVoPySYKmIevSfPyME8RggYv+V3uF8g1ehBSjn4vK83dERxrId10Fh+bkcc= X-Received: by 2002:a05:622a:4816:b0:4b2:919d:f37c with SMTP id d75a77b69052e-4b2e76f6ae6mr129056201cf.38.1756372320272; Thu, 28 Aug 2025 02:12:00 -0700 (PDT) MIME-Version: 1.0 References: <87DD95AA-274F-4F4F-BAD9-7738E5B1F905@yandex-team.ru> In-Reply-To: From: Kirill Reshke Date: Thu, 28 Aug 2025 14:11:48 +0500 X-Gm-Features: Ac12FXzgZJhBL6Y5U8d4K6DXYcDg5HQMcxqxvBgWimzyZ2aqBh988mv481SuW0w Message-ID: Subject: Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access) To: Melanie Plageman Cc: Andrey Borodin , PostgreSQL Hackers , Andres Freund , Robert Haas Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 28 Aug 2025 at 00:02, Melanie Plageman wrote: > > Do we need to pin vmbuffer here? Looks like > > XLogReadBufferForRedoExtended already pins vmbuffer. I verified this > > with CheckBufferIsPinnedOnce(vmbuffer) just before visibilitymap_pin > > and COPY ... WITH (FREEZE true) test. > > I thought the reason visibilitymap_set() did it was that it was > possible for the block of the VM corresponding to the block of the > heap to be different during recovery than it was when emitting the > record, and thus we needed the part of visiblitymap_pin() that > released the old vmbuffer and got the new one corresponding to the > heap block. > > I can't quite think of how this could happen though. > > Assuming it can't happen, then we can get rid of visiblitymap_pin() > (and add visibilitymap_pin_ok()) in both visiblitymap_set_vmbyte() and > visibilitymap_set(). I've done this to visibilitymap_set() in a > separate patch 0001. I would like other opinions/confirmation that the > block of the VM corresponding to the heap block cannot differ during > recovery from that what it was when the record was emitted during > normal operation, though. I did micro git-blame research here. I spotted only one related change [0]. Looks like before this change pin was indeed needed. But not after this change, so this visibilitymap_pin is just an oversight? Related thread is [1]. I quickly checked the discussion in this thread, and it looks like no one was bothered about these lines or VM logging changes (in this exact pin buffer aspect). The discussion was of other aspects of this commit. [0] https://github.com/postgres/postgres/commit/2c03216d8311 [1] https://www.postgresql.org/message-id/533D6CBF.6080203%40vmware.com -- Best regards, Kirill Reshke