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 1uRXvK-00DB2D-NL for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Jun 2025 15:08:30 +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 1uRXvI-00AYfL-Qv for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Jun 2025 15:08:29 +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 1uRXvI-00AYfD-Fe for pgsql-hackers@lists.postgresql.org; Tue, 17 Jun 2025 15:08:29 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uRXvG-002Z5A-2f for pgsql-hackers@postgresql.org; Tue, 17 Jun 2025 15:08:28 +0000 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-6070293103cso10296376a12.0 for ; Tue, 17 Jun 2025 08:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750172905; x=1750777705; 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=aX7aGC2TD/mZZfbN4uFwKDFH7/kQfNSxrc8qtREnvIc=; b=g467nR0VjCAuy6BwGTJ1cE+qoDS0Uhlf4U7UjGUkkRvuqQjsXL7ozUyFlcYgKFLBBO T5PNiFbjvYe8mHxSWEGH6HcgyX9hhGr/YioKNGs1M/L9C3qxK08j52OF6hX5tAI5v2w1 3lfgUVULI/7siYBNn4Yhghh8nb2PhJVEuLyFwleyPBo7t+jKG0bqdEjI73+jZVVFJ0px Q3fA7FAqXwrJ9asR2mW2Ld9Q64jpUIQUo6qls22m7qWAiBQVINEKoRBsGlrLL2rZYr6V atHmV4eDWNPeli+3c6/Doyj+/uut1yZw4Oe2rf/9ayKhZq/9huwrrirUDBRf+OqoTJID gU5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750172905; x=1750777705; 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=aX7aGC2TD/mZZfbN4uFwKDFH7/kQfNSxrc8qtREnvIc=; b=Q6IHzv/xw5TgBroG3zYBgNWi1KIIBdM7LJIMe8YwZMw12WrwBSkXqSQa10e6O1aIkD YD34Ro2h999YdN3uzaN78HF3zFcbHloHwSP8+hEDIT3FlCxwo0HcnY0FqAv4rUdHwFKb QXFGa/BlQHs12JLGsHUqMPe3gGZdaR21dumQK960wfBXEJdDvf/TMHH1/AOaRyqhaVgJ /O5WLMZlHGHHiDgSQq/1EqQ+ns60dtMacdV+IekFxSLxS7ptXC/X7jbc6RNI6VwmO+oz TkfgNLhvdnTcnxENSasWUIItZyVH0PEuRrKTiicqhAordvwdZMy6RdRghHb+72/QEcUM G2Zg== X-Forwarded-Encrypted: i=1; AJvYcCWWMxpfgvn4qWkOBBu6f8ECsXp4yJTIG6M9HOcDw+Zd7zgSuI6EKY8aeXMgkjjk2b5PG8ZVOIlpMhDAMpGm@postgresql.org X-Gm-Message-State: AOJu0Ywnmw4sN3OmkmshcOJGOnXhrC4foaU7u/JW/I0Tb+YIWUce3Uc0 z0q19V481yN36NiDhsh0sVTAmmSRBXtiKRIJL+mp0q5H/swT44zPURBK36SOZOcOyDDvaed0P8r CwsUkH55nbPn65AfJO3aazJxzZMWyxZ4= X-Gm-Gg: ASbGncsZNImUb6HKEUVOlhEhPqw593GVq8vC5krQtZbeCDuOMMBWorK1ZgUKg2bVep2 f2Gnm1vIc/XtTl0sB2C4OrftM4lh3E1S89rqZgN3+EFC7yCxmxmRF+5gquCB0AjMh8GCIY6f8PC +jWvWBKKYokFa5Blrvl3V9MGhx4Kx7S9XpqpTOg1FgPg== X-Google-Smtp-Source: AGHT+IHt0Lyh9XSdl5r4IwfsmGC4CZvzn27dL61RsHDdSdg7GDOUvRhN/+3yXEYSg8G2kj/7+43+9v6WJVqxGcihAH8= X-Received: by 2002:a17:907:3d86:b0:ad8:9c97:c2dd with SMTP id a640c23a62f3a-adfad435b42mr1431701866b.17.1750172903822; Tue, 17 Jun 2025 08:08:23 -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> In-Reply-To: <3f242e-68518380-11-78125f00@134027639> From: Alexander Korotkov Date: Tue, 17 Jun 2025 18:08:11 +0300 X-Gm-Features: AX0GCFsy3OuM-UbVCpN6M_cEFm4EyCtZv4ArnTzjellrSnqQR9hBaqOih2Z-tg0 Message-ID: Subject: Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly To: Vitaly Davydov Cc: vignesh C , "Hayato Kuroda (Fujitsu)" , Tom Lane , Alexander Lakhin , Amit Kapila , 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 Hi, Vitaly! On Tue, Jun 17, 2025 at 6:02=E2=80=AFPM Vitaly Davydov wrote: > Thank you for reporting the issue. > > >While tracking buildfarm for one of other commits, I noticed this failur= e: > >TRAP: failed Assert("s->data.restart_lsn >=3D > >s->last_saved_restart_lsn"), File: > >"../pgsql/src/backend/replication/slot.c", Line: 1813, PID: 3945797 > >postgres: standby: checkpointer (ExceptionalCondition+0x83) [0x55fa69b79= f5e] > >postgres: standby: checkpointer > >(InvalidateObsoleteReplicationSlots+0x53c) [0x55fa69982171] > >postgres: standby: checkpointer (CreateCheckPoint+0x9ad) [0x55fa6971feb2= ] > > This assert was introduced in the patch. Now, I think, it is a wrong one.= Let me > please explain one of the possible scenarios when it can be triggered. In= case > of physical replication, when walsender receives a standby reply message,= it > calls PhysicalConfirmReceivedLocation function which updates slots' resta= rt_lsn > from received flush_lsn value. This value may be older than the saved val= ue. If > it happens during checkpoint, after slot saving to disk, this assert will= be > triggered, because last_saved_restart_lsn value may be lesser than the ne= w > restart_lsn value, updated from walsender. > > I propose to remove this assert. Yes, but is it OK for restart_lsn to move backward? That might mean that if checkpoint happen faster than PhysicalConfirmReceivedLocation(), then crash could cause this WAL location to be unavailable. Is that true? Also, what do you think about proposed changes in [1]? I wonder if it could somehow decrease the coverage. Links. 1. https://www.postgresql.org/message-id/OSCPR01MB149665B3F0629D10731B18E5A= F570A%40OSCPR01MB14966.jpnprd01.prod.outlook.com ------ Regards, Alexander Korotkov Supabase