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 1uUJSS-001EeK-0D for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Jun 2025 06:18:08 +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 1uUJSP-000O5G-Si for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Jun 2025 06:18:06 +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 1uUJSP-000O58-JT for pgsql-hackers@lists.postgresql.org; Wed, 25 Jun 2025 06:18:06 +0000 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uUJSO-003y5k-0H for pgsql-hackers@postgresql.org; Wed, 25 Jun 2025 06:18:05 +0000 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-54b10594812so6167484e87.1 for ; Tue, 24 Jun 2025 23:18:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750832283; x=1751437083; 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=EuPF/Z6Tq74OZWhp77zCg2LDVSY0RHLghu41R+fyL3E=; b=ceVbelGvj+Wsn9lqeUikBqcH7zVEdVaIMtpLAKI6B3ay9H0VWp91QIsOXuFLy/nBZw M4sXNeCckmjRUKZl4ghawzfrGSlAhzwKwKPYbaqWcbl92aiV+bBUCFcdt/ozUCzOljTl Vm/SDcSXUeQ7jxpQpv46qjm/8GVmA2eSfM/0sRs/zWkicTNMsRu2yYvCoZ+WDvE5Ac4c RH9NrfCUJn60xGiqxPxaekLwsC17Glqzec4gqJnS0Al6JIZhwMuwO7vDojE8qAmo6T6h 9Y2IzUhZNEaV2V7hRdih41SCcMhxGr7VDDVwEk3xUoeEtMmA8XL+W3BvCKTbuIVbFN/v S77A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750832283; x=1751437083; 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=EuPF/Z6Tq74OZWhp77zCg2LDVSY0RHLghu41R+fyL3E=; b=hn2+cL5AhLdEl66m3f/9N4lgLqdBD5YyUZpLfM3robh3OgpwTpVVgq+lbTgC8QXU4R mddx/iW8gU2MQTOXhzLgfWlSx6ZNmbrXIZv9a/LDov+PuDf6CSUJAwR0ERUxNGiFgVcj FvEHpXySXuneD+3/N7IpkpA4rvBqMndyzrnsrZdnL0YrSu4UeTopzz4RuCLVon1NmbJB lFr1pUEIXGTVdFbVPoMyV/RUKVvwJf9df4LM2VTXAcRDh++eEy8Z0d6zqOLQl0bQdKef 3XPgMVfYKCsdBjuIsMYsBH0WAHcmPD/DtgzVOfJN/77vNDNliNmkOTzH3w3fMhJd4uzv LPww== X-Forwarded-Encrypted: i=1; AJvYcCWsfxUWqPanNuz0e9JqFjLUitwNvduh2RFTxJ3Q0KR0yYhZQKEUOvRB5tO5MugdMAmVgTW3fB06wn80Iriq@postgresql.org X-Gm-Message-State: AOJu0YyQcgqgwYsDpcRF3huuwS6YcfDrrmsv4lXMdRmY2cmWJFCf1vvT hg2RGpn1NFcinqmyj2uyT3CUMc/nftWS0j8kMgpIjxhSGqqGsnaGMG29JYVEP33lrZujzp5d3+6 KA/BQuf/2psw4wOFtnxRHxrCzQVvssLs= X-Gm-Gg: ASbGncsNdUozF70RKr1Pdz3fhS7SuomaCg5Dz+fEeo5JoyHqsDZQ4Uyg1O3MuCsnSeb cNx5n57swRy+fMOKSzzmJPQmVo5ZfzK/S6KjILL7beTCVTJbD8dIIJ5CRAVq+vZ188oWcxpoaTF K3SIX9O2N9DTM2mLBq2+4rg4Lpqe1H8Mj14kd+OyX8oXTs X-Google-Smtp-Source: AGHT+IGtf36wrfU0NS0oXohbk25s/an32MC8JwImUQ6gEdkdmpPaBnOgDcC2D+9osp00Dzq8T1ek7RSfmfJmLcg0jiM= X-Received: by 2002:ac2:568f:0:b0:553:2bf7:77ac with SMTP id 2adb3069b0e04-554fdd222d5mr579644e87.41.1750832283111; Tue, 24 Jun 2025 23:18:03 -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: Dilip Kumar Date: Wed, 25 Jun 2025 11:47:46 +0530 X-Gm-Features: Ac12FXwmrO02J7IfUDAR_Ov1vN9OEHFC2vA3oUfZW5u97OPN_kgrTdKzADICRNA Message-ID: Subject: Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly To: "Zhijie Hou (Fujitsu)" Cc: Alexander Korotkov , "Hayato Kuroda (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 On Wed, Jun 25, 2025 at 10:57=E2=80=AFAM Zhijie Hou (Fujitsu) wrote: > > Hi, > > After commit ca307d5, I noticed another crash when testing > some other logical replication features. > > The server with max_replication_slots set to 0 would crash when executing= CHECKPOINT. > > TRAP: failed Assert("ReplicationSlotCtl !=3D NULL"), File: "slot.c", Line= : 1162, PID: 577315 > postgres: checkpointer (ExceptionalCondition+0x9e)[0xc046cb] > postgres: checkpointer (ReplicationSlotsComputeRequiredLSN+0x30)[0x99697f= ] > postgres: checkpointer (CheckPointReplicationSlots+0x191)[0x997dc1] > postgres: checkpointer [0x597b1b] > postgres: checkpointer (CreateCheckPoint+0x6d1)[0x59729e] > postgres: checkpointer (CheckpointerMain+0x559)[0x93ee79] > postgres: checkpointer (postmaster_child_launch+0x15f)[0x940311] > postgres: checkpointer [0x9468b0] > postgres: checkpointer (PostmasterMain+0x1258)[0x9434f8] > postgres: checkpointer (main+0x2fe)[0x7f5f9c] > /lib64/libc.so.6(__libc_start_main+0xe5)[0x7f7585f81d85] > postgres: checkpointer (_start+0x2e)[0x4958ee] > > I think it is trying to access the replication slots when the shared memo= ry > for them was not allocated. I do not understand why CheckPointReplicationSlots() calls ReplicationSlotsComputeRequiredLSN() unconditionally, shouldn't this be called under the check[1], If not then instead of asserting Assert("ReplicationSlotCtl !=3D NULL"), this should just return if ReplicationSlotCtl is NULL, isn't it, because ReplicationSlotCtl is not allocated if max_replication_slots is 0. [1] --- a/src/backend/replication/slot.c +++ b/src/backend/replication/slot.c @@ -2131,7 +2131,8 @@ CheckPointReplicationSlots(bool is_shutdown) * Recompute the required LSN as SaveSlotToPath() updated * last_saved_restart_lsn for slots. */ - ReplicationSlotsComputeRequiredLSN(); + if (max_replication_slots > 0) + ReplicationSlotsComputeRequiredLSN(); } --=20 Regards, Dilip Kumar Google