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 1uSCWd-004hL0-Jv for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Jun 2025 10:29:43 +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 1uSCWb-00ALvp-EZ for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Jun 2025 10:29:42 +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 1uSCWb-00ALvh-3V for pgsql-hackers@lists.postgresql.org; Thu, 19 Jun 2025 10:29:41 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uSCWa-002rN6-04 for pgsql-hackers@postgresql.org; Thu, 19 Jun 2025 10:29:40 +0000 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-b3182c6d03bso802716a12.0 for ; Thu, 19 Jun 2025 03:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750328979; x=1750933779; 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=wFm2WniYkIuyyebdDDQrvB0DIYpCxok0LYgAlRLzP5c=; b=REil0BtaevtLc8kFQfloln+mD2vqwwbYvYH+U1JruGsDQgAx08uSfHGmNofwdi9M8W gDLPHlCcsW99pWZGC2+RA46Sbs/QhgeduScidmewqSpUVXrR8hA7tMwn7ti1C5SXGdV6 846PhmTg3YkNbbezV6k+08kjetTPwC55L6laKvFkeUNyTuD6SW9NkeE6wNEVDSsqcgZx pkXtgby0sqwZmer3Vp9uXlj+c2MqJ12mtbldw9ngrwL9SwZ5DOM18YA2LMNW3n0afg4E b9CgfCXKwYpbBJoNEge8FEzhRJPJGpdlVtq1hNSvQE9lRYpeVRj2LJvuyy0HwK6NeInA 7ZpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750328979; x=1750933779; 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=wFm2WniYkIuyyebdDDQrvB0DIYpCxok0LYgAlRLzP5c=; b=E+lf5NJcfwoJNDOvXJrGspFw38t54nTTJCzLGOpbZpyCbRhofLjlRi8W9SAl3uoBMe tXriY8ck5CBYjDrQeSTLknSVZ9RArH2UbhpFNKoMNLh3QVQpEjMKu71pF+jDm5Ds5L2u ZJE+8SLXG8iVm9wVcI8rJb2+hd9xys2iMVRnXoN/wwve8R5iJUClTq2wqGdux7cWl+hA K9B8twCJtZKEeqaONx0CYUMXEJ4jxh9Qd80aAtokvJCYcw/8xxo27ouBWIhfAFzypq2c EpU5+mk2sZFkxaRMb+LnMYrpOfwhjnkPEWZTs4P7pgp82BPgI/UOJtDtAGIfDaYKm0Ab TZUA== X-Forwarded-Encrypted: i=1; AJvYcCWwe2mE8/4rrn304lzZ1Krk5c6oYDH+CoJIYieZZFShVzi431fZ4X97h4WI3rbIhPzG7/7qz0OJ1N6brkli@postgresql.org X-Gm-Message-State: AOJu0Yzg8p/jo+pKNt80LpfasqcCm0qS6JTw/JnC3b3lfjnGhf4pTPCu wRND+1Ey5vnR6bM7L+umIRhaiwzfHWCX3J5XIO9XRoWDOjcPvc1lHVRm7BHb9S06bKd7fpI9Z1b lt6OYIRiQD+/DaLzdtjff9Dnym2aT3cc= X-Gm-Gg: ASbGncsSeRWVnZOUAEWZtKCEbyAktUTVG2rEmoHesUQUHaFKg1HZBgWFJ/m0oo2U3PY MQddx2aFHXiKoZWhiznf8yCwjwPQVRNBsY4oxRhsxJleEfsEbdZ7/tPMusdAbP5neNStPlUMhGz 0MPcY8EWYxNWe2/BGD6JQiBTxkHBrAxGcePAiBqokiaBM= X-Google-Smtp-Source: AGHT+IFkelTbo6kfsRYPxMMl3ZLR5w7dQMNinB8oukfFAUSOGe4UBh+zjHWy/HeIxG/pBI/Xn45pJZ723QqLuZfgL0k= X-Received: by 2002:a17:90b:3907:b0:313:f6fa:5bb3 with SMTP id 98e67ed59e1d1-313f6fa5d88mr23120378a91.26.1750328978854; Thu, 19 Jun 2025 03:29:38 -0700 (PDT) MIME-Version: 1.0 References: <1d12d2-67235980-35-19a406a0@63439497> <1d97ec-6841b600-3-b7b4780@40747246> <28c8bf-68470780-3-51b29480@89454035> <0a617d34-abc3-4090-92a5-ea15d45e36f6@gmail.com> <228607.1750003556@sss.pgh.pa.us> <3f242e-68518380-11-78125f00@134027639> <214ba-6852df80-9-7e0df800@134698799> <21b44-6852e000-3-a556820@87831171> In-Reply-To: From: Amit Kapila Date: Thu, 19 Jun 2025 15:59:25 +0530 X-Gm-Features: AX0GCFtHQ1Y3oL6qPqSXhGvHHIYQOrjzkII8PhuXE_nOBF9P5hbNO71_VKc_Ux4 Message-ID: Subject: Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly To: Alexander Korotkov Cc: Vitaly Davydov , vignesh C , "Hayato Kuroda (Fujitsu)" , Tom Lane , Alexander Lakhin , pgsql-hackers , Masahiko Sawada , "tomas@vondra.me" 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 On Wed, Jun 18, 2025 at 10:17=E2=80=AFPM Alexander Korotkov wrote: > > On Wed, Jun 18, 2025 at 6:50=E2=80=AFPM Vitaly Davydov wrote: > > > I think, it is a good idea. Once we do not use the generated data, it= is ok > > > just to generate WAL segments using the proposed function. I've teste= d this > > > function. The tests worked as expected with and without the fix. The = attached > > > patch does the change. > > > > Sorry, forgot to attach the patch. It is created on the current master = branch. > > It may conflict with your corrections. I hope, it could be useful. > > Thank you. I've integrated this into a patch to improve these tests. > > Regarding assertion failure, I've found that assert in > PhysicalConfirmReceivedLocation() conflicts with restart_lsn > previously set by ReplicationSlotReserveWal(). As I can see, > ReplicationSlotReserveWal() just picks fresh XLogCtl->RedoRecPtr lsn. > So, it doesn't seems there is a guarantee that restart_lsn never goes > backward. The commit in ReplicationSlotReserveWal() even states there > is a "chance that we have to retry". > I don't see how this theory can lead to a restart_lsn of a slot going backwards. The retry mentioned there is just a retry to reserve the slot's position again if the required WAL is already removed. Such a retry can only get the position later than the previous restart_lsn. > Thus, I propose to remove the > assertion introduced by ca307d5cec90. > If what I said above is correct, then the following part of the commit message will be incorrect: "As stated in the ReplicationSlotReserveWal() comment, this is not always true. Additionally, this issue has been spotted by some buildfarm members." --=20 With Regards, Amit Kapila.