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 1uUnuR-008min-Dk for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Jun 2025 14:49:03 +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 1uUnuO-00Dj8K-Nj for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Jun 2025 14:49:01 +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 1uUnuO-00Dj7p-E7 for pgsql-hackers@lists.postgresql.org; Thu, 26 Jun 2025 14:49:01 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uUnuN-0047M2-1R for pgsql-hackers@postgresql.org; Thu, 26 Jun 2025 14:49:00 +0000 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-ade58ef47c0so241438266b.1 for ; Thu, 26 Jun 2025 07:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750949338; x=1751554138; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=3JxWbKK2a5YFwqVZ6AI/IhTC3OUpuJ5cJUjNDiewWDE=; b=hKc17c+0LqiC3mpJ3vLT1s+AqCE92pssX7C2JG8CaO92/njxH6Rlw2BtQFnczcTzwC 5+7vfOg2MJDvz1MdTcpik5GKgtvmgVQInhqg578O2GTKBBx/N/ETnzoylCnPqaISmDCK PavBKqOSqt40pmr6JAAyQrKVLdQNPG7R+9ABkDOeW5j93GET0LqVOT/u+rg26kXcGO65 p30GmCL9AmZlTnJFYAmmI9ftCL4V6++Dqg85Qxjl4/qE5CyJfpAnO4RSHISD8O+WHfWh NP6B33idoQEAEbythYAcZ/qKBBA5AxsXcq6vYMO7/Iie1Sp+ksXX06MltZ0adA3VHqRO 5GfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750949338; x=1751554138; h=content-transfer-encoding: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=3JxWbKK2a5YFwqVZ6AI/IhTC3OUpuJ5cJUjNDiewWDE=; b=mOT3aBD+W/CXzx3QQyqxSOCHRd2M9piFFKHGxMsZ1LzuLyIHu2YjYZXFv13M5F85RS 0NwDoDH2X/R3Oz2Buu+eUMUF/PRLLjYkcSX+zjipdXzkzBkTDrJFZsQZB2FvwsUL4Flc TPuFqP/G5LWJBtG8clRZf2Bdihi0X0n4+4F1lgoVIQVE8Uzc2NKdfbRPsBrdFskcvpuz zRZvE0l3JLw3dtth9shQdOftgQkqrJhsbnFiIJMB8iYf5+McOLk2Erl+z8yBPR+Gao+x nUozQgqnakNHmU6CiFpU8Xki2CPSgojNXYPscRPQ/gh1866WmQQFHd3y6P0ZTgMM2QwG r6RA== X-Forwarded-Encrypted: i=1; AJvYcCV08ol1Xp5swiYJae039M0AHUukBNLFJPes33O2dq6oPUUGQ9znAZT/PfBkvuQKOrlNrZVgEf9gluOkcGGF@postgresql.org X-Gm-Message-State: AOJu0YyI1MGoQQoAKsJ2DIFkSrA8sfzWh/i/6W3FEf4dQevnK0ebu+WB sWZdWf+KJp/du+ITnjz9nKZSF3CjQe94A3tPUhS3NhJ3cKIDD73phKr5VnpZsMZ7jdkeYGE0gdA 7qCBAVdTlsz1YEV8fo8oXGYwdX4HxSNye/OyHPlI= X-Gm-Gg: ASbGncsh+fShYO1xJD/bCJU3as4TNtzPeIplBT3taTRJO+P6S1EXeCc9ItQwlC/FcS6 p3nDYqV8iE1+DahYd2wqQeWhuB/u4XNn40qFOPqhE95prfpxFGlamn/h+CzsOuLRi6H5vPSqH16 k3H04Bb8hVJpO4J0icXUuKRLRkBPv45xRKld27tuNHoTs= X-Google-Smtp-Source: AGHT+IFRC3KI//9AUMQl9P+w2QWKmU3qymbcShV0RpI6/9hHPW0/lGicyHjYqvVOcKDTuqtpMwFi3uo+imrzrTB8+zc= X-Received: by 2002:a17:907:60d6:b0:adf:f8f3:ee16 with SMTP id a640c23a62f3a-ae0d273090fmr337998366b.15.1750949337199; Thu, 26 Jun 2025 07:48:57 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Alexander Korotkov Date: Thu, 26 Jun 2025 17:48:45 +0300 X-Gm-Features: Ac12FXwPHazM2bEX0_3HOsI_ib_fR2AQBnYp7pCG9enWECtgEcOzSqUzDxTj160 Message-ID: Subject: Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly To: "Hayato Kuroda (Fujitsu)" Cc: Dilip Kumar , "Zhijie Hou (Fujitsu)" , Amit Kapila , Vitaly Davydov , Tom Lane , Alexander Lakhin , pgsql-hackers , Masahiko Sawada , "tomas@vondra.me" , vignesh C Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dear Kuroda-san, On Thu, Jun 26, 2025 at 6:46=E2=80=AFAM Hayato Kuroda (Fujitsu) wrote: > > Dear Alexander, > > > > Good idea. But I think we should associate the "updated" flag > > directly to the fact that one slot (no matter logical or physical) > > changed its last_saved_restart_lsn. See the attached patch. I'm > > going to push it if no objections. > > + /* > + * Track if we're going to update slot's last_saved_resta= rt_lsn. > + * We need this to know if we need to recompute the requi= red LSN. > + */ > + if (s->last_saved_restart_lsn !=3D s->data.restart_lsn) > + last_saved_restart_lsn_updated =3D true; > > I feel no need to set to true if last_saved_restart_lsn_updated is alread= y true. > Other than that it's OK for me. Thank you for your feedback. Regarding last_saved_restart_lsn_updated, I think the opposite. I think we should check if last_saved_restart_lsn_updated is set already only if it could promise us some economy of resources. In our case the main check only compares two fields of slot. And that fields are to be accessed anyway. So, we are not going to save any RAM accesses. Therefore, checking for last_saved_restart_lsn_updated seems like unnecessary code complication (and I don't see we're doing that in other places). So, I'm going to push this patch "as is". ------ Regards, Alexander Korotkov Supabase