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.96) (envelope-from ) id 1wQHLu-001Ozi-18 for pgsql-hackers@arkaria.postgresql.org; Fri, 22 May 2026 04:19:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wQHLp-00CGHK-2L for pgsql-hackers@arkaria.postgresql.org; Fri, 22 May 2026 04:19:10 +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.96) (envelope-from ) id 1wQHLp-00CGHB-1G for pgsql-hackers@lists.postgresql.org; Fri, 22 May 2026 04:19:10 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wQHLo-00000000pxQ-11DV for pgsql-hackers@postgresql.org; Fri, 22 May 2026 04:19:10 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-2b458ca2296so49479825ad.0 for ; Thu, 21 May 2026 21:19:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1779423546; cv=none; d=google.com; s=arc-20240605; b=CPVtO4wa+8N92bwlfgq4U5KDi0i0SkRk5XTMri1zuga44+om8AGB42ZwHNeIzxKcbZ vGMDraBhfxg/QXIAi169Vbr/Jw1y4FBHmb+j6Dl+p5MG0lMH7TCBauVlbbWzwcqr7itw gYOnJ37Y4NVc0oltS6RxxT+nPV4rSaFhkqdxissT6Ph3Xd1uX9cllHIg6A2B+wzUvIda +UnV8IdpodTNqIFavoUYJKhP+UqVDLIa/gE5FeMbAabDIUMgwyB3Rsn6wJQ0W7p2DXCd uVR/GmMLj8nvOVHDqdZ7/artWZCrnuLqdiMSRbHLrmxNk0otaGjQ3Bayw1mUHNq96NU9 yofg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=fKxNvbv18fl77Qb6i/m7m4zS5Ul5HMbwEKo62NWued0=; fh=WBoP2BFkz0Lcmxo27y/UXE8oKU6Yyt75CVQw4LBw7Yg=; b=dRNo+5eoRR6OF1ve2K1Pk3kF2BBjXg3lL9OEmVBNYZ2yNsMPdc5XiJyFQ841nnC2LT CgRX6QFUJlVLAHRJPdvkSWZD1YgngOwj9zGgJN1EyyMgQwLCL7B7khA/OvYyWVIrZQ59 sqdn157S7OvWo6Vz0d2BFIc37gkjpLkZ7H9HqS5YHSiQ+HE7HfSgXMISOfOJ+y/ORm4I gdq1m1RRS8nl7AziB0SUv50qj9CPkbn7TDceIygl9cHNTbXjOlXhKcmIWPCRHzZUg6Zs yWSK0lhA+1rV8FDI5Vl1NzYz5d8Dcu1J9cdK0WuRvxR1gS8A2ook9WshMGYz75hYNhhU GuWA==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779423546; x=1780028346; 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=fKxNvbv18fl77Qb6i/m7m4zS5Ul5HMbwEKo62NWued0=; b=VCi53RFlBUxpbMynH7eoUsyIhewkMTZTZn1fDLJIQdPfZpRZXN877KHATq+JRuSUNZ UvWy+S8Hvn2beWTTYSNcEKR+0l391le9fpDGFhobBC2lgaGun47EB/ZhJoIgzB2Gv1+b aFXxCfLMHllW+FbcZVX+vcuEjZ4LkMTpWY5yT5FphMXzj6uXcmiERIHYxs2TR/hzAy0h +0uxKsYE4sH6WBmfBfWitXtcJGEfgGO9TLQCblW0krdgzWoZMhqhV9CJbHZP4kP/3v0G FJDqjGGcyvJgJvCvPvy14TB7JsEQ30UHQ0yDF/Xdg3cTaRPQjdPMi0QmYZr2POPPKnPn bZ9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779423546; x=1780028346; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=fKxNvbv18fl77Qb6i/m7m4zS5Ul5HMbwEKo62NWued0=; b=aZfferwj8RZp7PlngnSk7HXTesM7+a2SVYT2l149FM6DR3hG8Treexg9MVWS3gD8x1 /ExwfEDmLsNWp971dTDPJQPod+NqDw8VbBDOVB17BJWSEkN4NjAtZdF8FlaxsoeW4k2S LwBQwkgP2+vQR24xjjSSCb5QMDB5W6Uh/FiWARlsI56AY7Yg97cGUwW7b0BZM9KiTsf3 ZjZwUV161Z4UL1ezBR23Sn28GXQypCY5bH3XNtUVZL5Iba+NXDF6DuqX5x9PRNcHWrbl qnRC65tfPs7QRToOmyZSjtE6hBzM7Il8CspJPbbnVB3BK2cCUF0sA5twpBFe/lnSij51 rGVw== X-Gm-Message-State: AOJu0YxscvsgywIJerGzaWbwdLwBX3lRe1t4kSpSPeffAR3mNBb77lt2 u5r61ChMwreW50OXMjDUIEYykENJHAakP8wBI6PWE3SsQYsbF9SfCfCZtaVpxvrya+kfWE/ODTa 9vMEGcvnQkaUVfRiO8Cqxfe5JaHWezOo= X-Gm-Gg: Acq92OGTNZ/GFSMhitjt/+SzbC+OxUXEVpQeMalRuyZ9xjg6PJ1N8NnKt++VV/ky1pp UZ156Wnq+iVPGGw11+Pu1fauidzfJQTUl5K56t9ElJ97EKNArHvW9TcOldGWMsjuF1PYNhwUDHc s+Z6CCHk9dtlnMK5hSfZbMzfHajWvR5aSIkaSu4MTkga4FTfDORGnupJz/ievCe41ySupcJDtOe uORuJjWsI+il3Rlmnpp68Mi8cbrCI0wQyOGmx0j51Sj6K9jEtPZ7wWKb6bN4BBZ77DvXs2lMfFP 63GOunGhRCRii2k6XHXsP/3ocqXyM6l2LVtvla2a50SY3DYTzVfQoX6Kuu9XFe5D X-Received: by 2002:a17:903:1a70:b0:2b9:ec37:2977 with SMTP id d9443c01a7336-2beb06bf9d7mr18808855ad.38.1779423545746; Thu, 21 May 2026 21:19:05 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Fri, 22 May 2026 09:48:54 +0530 X-Gm-Features: AVHnY4K59tU5hg4xaN8jbwU3wJh2HxFYxxWrRdw6luB2FG7Y6nUknKuln23yds4 Message-ID: Subject: Re: effective_wal_level is not decreasing after using REPACK (CONCURRENTLY) To: Imran Zaheer , Sawada Masahiko Cc: pgsql-hackers , shveta malik 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 21, 2026 at 10:02=E2=80=AFPM Imran Zaheer wrote: > > Hi > > The recent support for dynamic toggling of logical decoding (67c2097) > disables logical > decoding if no logical slots are present. But the repack command doesn't = seem to > coordinate with this toggling. The effective_wal_level is not > decreasing after using repack concurrently. > > postgres=3D# show effective_wal_level; > effective_wal_level > --------------------- > replica > (1 row) > > postgres=3D# create table foo(a int primary key); > CREATE TABLE > postgres=3D# REPACK (CONCURRENTLY) foo; > 2026-05-21 20:46:25.423 PKT [1591896] LOG: logical decoding is > enabled upon creating a new logical replication slot > 2026-05-21 20:46:25.634 PKT [1591896] LOG: logical decoding found > consistent point at 0/018F36D0 > 2026-05-21 20:46:25.634 PKT [1591896] DETAIL: There are no running > transactions. > REPACK > postgres=3D# select slot_name from pg_replication_slots; > slot_name > ----------- > (0 rows) > > postgres=3D# show effective_wal_level; > effective_wal_level > --------------------- > logical > (1 row) > > > The server has to be restarted in order to decrease the > effective_wal_level. REPACK CONCURRENTLY uses a temporary slot that is > dropped at the time of cleanup, but logical decoding is not disabled. > > This may be related to both commits, 28d534e and 67c2097 > > The attached patch adds the `RequestDisableLogicalDecoding` call to > `repack_cleanup_logical_decoding` after the replication slot is > dropped so the checkpointer will take care of it.. > Thanks for reporting the issue. I agree with both the problem statement and the proposed fix. The fix LGTM. The only point I=E2=80=99d like to discuss is whether it woul= d make more sense for RequestDisableLogicalDecoding() to be called directly from ReplicationSlotDropAcquired(). Currently, ReplicationSlotRelease(), ReplicationSlotDrop(), and now repack_cleanup_logical_decoding() all invoke RequestDisableLogicalDecoding() immediately after ReplicationSlotDropAcquired(). Given this pattern, it may be cleaner and less error-prone to make RequestDisableLogicalDecoding() part of ReplicationSlotDropAcquired() itself, which could also help avoid similar bugs in the future. That said, one concern is that ReplicationSlotsDropDBSlots() could end up issuing too many disable requests if there are many logical slots in the target database, so I=E2=80=99m not entirely sure whether this is th= e right direction. Thoughts? Copying Sawada-san (author of the original patch) too, to share his thoughts on this. thanks Shveta