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 1uJZrC-002CFY-8i for pgsql-hackers@arkaria.postgresql.org; Mon, 26 May 2025 15:35:18 +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 1uJZqB-002QTU-6c for pgsql-hackers@arkaria.postgresql.org; Mon, 26 May 2025 15:34:15 +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 1uJZqA-002QTM-P1 for pgsql-hackers@lists.postgresql.org; Mon, 26 May 2025 15:34:15 +0000 Received: from mail.postgrespro.ru ([93.174.132.70]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uJZq7-0003PI-2b for pgsql-hackers@postgresql.org; Mon, 26 May 2025 15:34:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1748273648; bh=DeeMNf5bTl0x4c5NXEcd+FYVs3NEmdfBMRXpZCLSnzo=; h=From:In-Reply-To:References:Date:Cc:To:Message-ID:Subject: User-Agent:From; b=TBQD0RxggQpoTorigEFDim+TmTGAzraZoW33zMz+XedJPgbivZLjfv8RWXEFZSBqo JsPw+EMYTAIZyB7ZgXYvbMZKi2uXKCkk3dZLtK5UltYWRkgRfIZHukEgw0KpIhesId rHqN7u7z/CiJywPXqTrmtfgZb8WHyHv27PDbmSCB7LW6vQTO6jkhUoHXOJQW+Af3iE /zEfWiltD+3orBb8wXDZ657Qs04rK6X8S9q52eGRok1bwkOA62SdHRkKQIk5pSkapw S5JnMeHHZ8hoL8Mbetkr7gcwaw+IGvX61U1btdJdq5dQXbISK6SxJSJg+Zq3mVpRLt RbMzrmWRz7C9A== Received: from sogo.postgrespro.ru (sogo.l.postgrespro.ru [192.168.2.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by mail.postgrespro.ru (Postfix/587) with ESMTPS id C3E466082F; Mon, 26 May 2025 18:34:07 +0300 (MSK) From: "Vitaly Davydov" In-Reply-To: Content-Type: text/plain; charset="utf-8" X-Forward: 93.174.131.138 References: <1d12d2-67235980-35-19a406a0@63439497> <683f3c82-d38e-436d-88fd-27722af62005@vondra.me> <8679fea7-94ce-4a52-8e48-1a8cd0857fcb@vondra.me> <135e8-675c4600-21-304d7f40@228322535> <1538a2-67c5c700-7-77ec5a80@179382871> <27589a-680a4b80-6d-6e07880@117064404> <3ea6a1-68150580-1-7b53be0@80017081> <309f08-682ca380-25-139bf240@62751029> <2c1d-68344100-b7-3411b8c0@256938178> Date: Mon, 26 May 2025 18:34:07 +0300 Cc: "Alexander Korotkov" , "pgsql-hackers" , "Masahiko Sawada" , tomas@vondra.me To: "Amit Kapila" MIME-Version: 1.0 Message-ID: <1c372-68348a00-11-62e0b680@177489907> Subject: =?utf-8?q?Re=3A?= Slot's =?utf-8?q?restart=5Flsn?= may point to removed WAL segment after hard restart unexpectedly User-Agent: SOGoMail 5.12.0 Content-Transfer-Encoding: quoted-printable X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/05/26 12:33:00 #27583800 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dear Amit, > OTOH, if we don't want to adjust physical > slot machinery, it seems saving the logical slots to disk immediately > when its restart=5Flsn is updated is a waste of effort after your pat= ch, > no? If so, why are we okay with that? I agree, that saving logical slots at advance is a possible waste of ef= fort. But I don't understand original ideas behind it. I haven't touched it to ma= ke the minimal patch which should not break the existing functionality. We trim WAL in checkpoint (or restart point) operation only. The slots' restart=5Flsn is used to keep the wal from truncation. I believe, we ne= ed to compute the slots' oldest lsn as the minimal value of restart=5Flsn val= ues only when executing checkpoint (or restart point). I guess, it doesn't depen= d on slot's type (logical or physical). We have 0003 patch to fix it. I haven't deeply investigated yet slot's xmin values but I guess the xm= in values are a different story than restart=5Flsn. It is used to avoid tuple del= etions by vacuum and it is updated by a different way. I can't say that LogicalConfirmReceivedLocation is the right place to update saved on di= sk xmin values. I would propose to update these values in SaveSlotToPath under = some lock to avoid concurrent reads of unsaved values or do in a checkpoint like = as for restart=5Flsn. We may investigate and improve it in an another patch. With best regards, Vitaly