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 1uM3jt-001cYr-3E for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Jun 2025 11:54:01 +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 1uM3jr-009Q4E-OH for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Jun 2025 11:53:59 +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 1uM3jr-009Q45-Cp for pgsql-hackers@lists.postgresql.org; Mon, 02 Jun 2025 11:53:59 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uM3jp-0001ho-0A for pgsql-hackers@postgresql.org; Mon, 02 Jun 2025 11:53:58 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-b2c41acd479so2814627a12.2 for ; Mon, 02 Jun 2025 04:53:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748865236; x=1749470036; 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=URPPSsuXUsiRKw5/A+qPUPVN67VkEkqq89mmJBFv/W0=; b=XnVOk9URTxp/GL9yKBSaBm2jcJFYxlHn8Cm/mvUUJbmp7dexRq1CBUsDrkrm1/V5jB 6VrxUC9us8XCvu+vQTkneIdQ0cACnAnLFtsvcAPnfmoxj0iRUuMx3Hu4aegJhlRhXhJZ 8u7hwIV+M7QWo8T2HGJqQUZT6lU6wOYr4jGhx7nMSiJ6ARj9/ianPTKKcJhvB14sXUM5 k/lCxEXG93+xXvG5upsgGN/HJ1jwoVw2H2ymUacYG9KKPkzvMlMH2IliIOiIoNYrWMtw Tt3dwyhl/20Vb7Jh6D7jhYccNORkaBAI+BUhMQMRye3ALShiGJlN3jXqdEc7EhHp/T0y 6EDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748865236; x=1749470036; 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=URPPSsuXUsiRKw5/A+qPUPVN67VkEkqq89mmJBFv/W0=; b=k4/yVSsBsnAfL8bsmqV2/WjoRzYgOwpQA/vMAdfK7dqMual8xigFW/amW7uFc1tpJj eGYbfUdSTmjQwzafhOF0+mA4azcGrj3jURO+oMpjgU1+95tCdB4GjX33OClmgCLqIFVk 8/YLSfqzGHLfBwu2jdT9JjxgbhVTfocpPstd2evr1X9f9wP3+ZkEGmkj2i9na1IBCdYB 04kg/7SNtEFLswGlvT3N9uB5WKK5P70lxkGYyerCd8QEZRVVx0HnedKwSeKF48UE89Rn xvURcuF3ZZfREdWe21B61nFS2FFRubm+xxAqIrYKy1z6RkL9N3SYmieDOugvGNUcuG1p apoQ== X-Forwarded-Encrypted: i=1; AJvYcCVD+NcblBEHWjJvo+Fr5cLvYpvD4DCfq9qBN8frVDAAUCwQ9EIzYydtluLgaulW5Y5bpaQ7XLb9W77qSU5v@postgresql.org X-Gm-Message-State: AOJu0YyLGMH7DIM0bGNsPcAB23L+xF9wVzb5JiI47XV0HvqUFdwHjXN+ PaayUvCfyrQ/re8OZ/0FaWp4pZ83B1n4cU6BeuDKRTYri2n0FFlmpROfd56RmfH0l2rqLTCNC5/ oXrS7yi9g/sZgEMzkuUX+cpgrXan+5Dc= X-Gm-Gg: ASbGnctTlwBbzWu0Mm0JIgInsixLCOm9f9CqmKl0hoqBdTyyGypgdhyP6mQLa8U19pX Q55wrK3jtqINLfnvaoo6nvUURbJV/MnNXVTiPWXgfSoeuEFCr2bl0qVrd3JdscapckwuxuaSLB3 vmjTUz882T7DalCdrcDitaGbdF277YA8/CDF9bFTtZfw42xg== X-Google-Smtp-Source: AGHT+IHVO6TmJQEJgxMbg/ObhHb6YqGbywMrpei41/Z41ELEtWAZKf90zhTxy2VBvCj38y4qdRqWq08XBxTxmQdXDq0= X-Received: by 2002:a17:90b:1e08:b0:311:9c1f:8524 with SMTP id 98e67ed59e1d1-3127c6d94b5mr12468684a91.15.1748865235628; Mon, 02 Jun 2025 04:53:55 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: From: Amit Kapila Date: Mon, 2 Jun 2025 17:23:43 +0530 X-Gm-Features: AX0GCFvP_yFVfqpGzb5gwyNszcdJst1hZFAxdn12qfvx2LcOdik1C81iMCUIiMY Message-ID: Subject: Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly To: Alexander Korotkov Cc: Vitaly Davydov , 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 Thu, May 29, 2025 at 5:29=E2=80=AFPM Alexander Korotkov wrote: > > On Tue, May 27, 2025 at 2:26=E2=80=AFPM Amit Kapila wrote: > > Yeah, we should be able to change ABI during beta, but I can't comment > > on the idea of effective_restart_lsn without seeing the patch or a > > detailed explanation of this idea. > > Could you, please, check the patch [1]. It implements this idea > except it names new field restart_lsn_flushed instead of > effective_restart_lsn. > This appears to be a better direction than the other patch, at least for HEAD. I noticed a few points while looking at the patch. 1. restart_lsn_flushed: Can we name it as last_saved_restart_lsn based on existing variable last_saved_confirmed_flush? 2. There are no comments as to why this is considered only for persistent slots when CheckPointReplicationSlots doesn't have any such check. 3. Please see if it makes sense to copy it in the copy_replication_slot. Apart from these, I am not sure if there are still any pending comments in the thread to be handled for this patch, so please see to avoid missing anything. > > Now, you see my point related to restart_lsn computation for logical > > slots, it is better to also do some analysis of the problem related to > > xmin I have highlighted in one of my previous emails [1]. I see your > > response to it, but I feel someone needs to give it a try by writing a > > test and see the behavior. I am saying because logical slots took > > precaution of flushing to disk before updating shared values of xmin > > for a reason, whereas similar precautions are not taken for physical > > slots, so there could be a problem with that computation as well. > > I see LogicalConfirmReceivedLocation() performs correctly while > updating effective_catalog_xmin only after syncing the slot to the > disk. I don't see how effective_xmin gets updates with the logical > replication progress though. Could you get me some clue on this, > please? > As per my understanding, for logical slots, effective_xmin is only set during the initial copy phase (or say if one has to export a snapshot), after that, its value won't change. Please read the comments in CreateInitDecodingContext() where we set its value. If you still have questions about it, we can discuss further. --=20 With Regards, Amit Kapila.