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 1wQLha-001TZ3-1h for pgsql-hackers@arkaria.postgresql.org; Fri, 22 May 2026 08:57:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wQLhX-00CmUg-3C for pgsql-hackers@arkaria.postgresql.org; Fri, 22 May 2026 08:57:52 +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.96) (envelope-from ) id 1wQLhX-00CmUY-1s for pgsql-hackers@lists.postgresql.org; Fri, 22 May 2026 08:57:52 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wQLhW-00000000FKT-0Yuc for pgsql-hackers@postgresql.org; Fri, 22 May 2026 08:57:51 +0000 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-36974217d4eso4515672a91.2 for ; Fri, 22 May 2026 01:57:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1779440269; cv=none; d=google.com; s=arc-20240605; b=XGOQe4SDmC/H4vCR4ShFiM74sxKccyyEQt1SCci1xr66ZHx+R9YI5lD95jLXkVYDxh eOJNQuuzE4Qf8s7ujBxHuHfOpzpectL5e+DUqs49/Izi4F928ZUJlnMimkeYZrHXUfmG 0/mXh2xdIa6bvf2me0n68aNWapHlMjy26EZGztCcS6a5WeHV5Im1djKZaDzyP/gVLX7G 3XZ4NVoLo/mxUpoUFzNI6m1KA/HZHRPSfKPexZg+q3qvXHbU0YfUFiZCP7FsEZ0tyXX9 Q7w9dyZdlWhZ2J+GHZG1mWGTozp6flcPTtZR6FIblf6aoIHx63XOfiQC3tkQqPRdQvf3 deUQ== 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=TRUnbD6d82j7oxmX/JNQm8J9jAyodqGEsj5SeTorDik=; fh=YJ6+j4DLmOerwtdgDsuaC6I4E5csZMQBfkDJh1uQl08=; b=BbIYc0tdz9OsgthtNfz01f4gHQ0O+5sMHeXLLK8cmr6FpzKdH915p6Pz2/50LeHPPm 9Pa4fBeyZ0ZEbnIti/seXPt5A8DQhSbvBmOP4FiU86AW2CVIpc8+OqsSnD+QQFlLP2Px ZTCPMUB7RSyvzkbhNYtQuj/J+/3x0ccGdtDjhndNXxREDxycXBNQOD4UhMjfBW9G0kTB DmgX9LAJn0J/6YPulzd4U7uyYbs9l02PZWV2UTSHswL7Ts7ojwYrZZGCrgsnRscGekai a9tyiJibashGce/BX47huTbUgLMA2Y1xtGJS/UFriR2lM0ksxewpEJG4GuJ+Ayc1NCkY 3lHQ==; 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=1779440269; x=1780045069; 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=TRUnbD6d82j7oxmX/JNQm8J9jAyodqGEsj5SeTorDik=; b=dUynCQvt5t6MfPWQRQ0hQ8l4oNKr/pA3i0QEsBYoBsAqvdkKfHwEqEKLMW3dXjXK19 EsFMtyc3m0gSbK97aTRGXpmFZQ7urgxft6oz+2VWNJBX2XrwUFj0D5axLVR9GXPdUm0F J4TGHGR6+mLoEqgjyfDIpi47qEvcpEBr3XKb6DgsIuHVgoPxEn82AIjmJ+LypbOioX+w Gvf83VGLjPY5sFrf/vF/1uTYm11nuCd6H0pA8aLdUgBs783iqNkxFGLQx4Ux8JyD/INs LwZnVadSGGz+TOG4I3xs9fL8pDIRifsLAyzhhjxflxfNuclBMRXH9wksuaEuO7L8HNnJ hlEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779440269; x=1780045069; 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=TRUnbD6d82j7oxmX/JNQm8J9jAyodqGEsj5SeTorDik=; b=CwozC3KwEug+f8RtrdvC8KDPJgzlJ3ejJzaNwl/M+QOWo51p6eQvcb0S0s6tOuqrT+ mdhGU4W84+p1Ai0EGmvmwFo8il9ZVN68mjoCpbMfR53gKBVtE2hdk7eun4sM8TKwr/+3 1ft6LUxRM23dyEPI4SC518wRgOYQXL4txGXzLnI34m14WF6rEROaexciChMQQg+Grxo5 aLcsyYy+iBsVPwj+K4GhC0qSAQlYmQ9+O94TczzZZN2WWgztPhxjzEWRdXuydMqZ1lCB lkcM56qh23AKV27f6U3bTmCYSI2Z+HaDUk2ewt2uOoXMEfYHIe0BHXBLSo/8gUXwgIq4 z9iA== X-Forwarded-Encrypted: i=1; AFNElJ+tPWdTNKDQcPVUR5/yOSaONuh5Df7yydJ7Xl3TIocw+iYxhRTyBgDU2NRNpHmOSYsHkjou1CYcA1undvq4@postgresql.org X-Gm-Message-State: AOJu0YzJNXSEJ/PaFpuxGI0RXHwl4UEOreM7E6OdGBSkW+PaAy7sg8TF dwRh8xqv7smlT2NJFQxhXoSue/vMT1Iwpr9W4TwdYEUaAth1KU3zIduyi+b+1C9SUDya6my2sds ogvZuAwElmNKp5BSqrxMiQP5XAKP7iFQ= X-Gm-Gg: Acq92OHis8pyHg7Nkdy3jQ3gxq4kAtiATQMGs7LKH4KDWdqXf6tA35DaoCtumkTbeRA zIL2V8Df1iD7q76Z9/NtbOjvu0u5SiBKY+4DKC3LeTrWMv9oZ9IMyn9VTjbSL+dgQ0vtbUpTozQ U+HMJz9GUTcZdhc+yx9FCJ06WdCPes061ZY3xRN5fSilvha01mMNmtvRwtM8ry0YQXxvQyxG0Nv Olhke4v0HhFwjGDEJq80ydk/R7jIUPz0gVrQebLTjP3tsUGRuHHeBMKk31sO1FjirSWg/TT7W8e 7tRD0VffdHkV28qwne4vuOD8HmsWQf2HNjleH+OLjPEvaEHecxPgSw== X-Received: by 2002:a17:902:d50c:b0:2bd:105c:91cb with SMTP id d9443c01a7336-2beb059e13fmr30011845ad.15.1779440268957; Fri, 22 May 2026 01:57:48 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Fri, 22 May 2026 14:27:37 +0530 X-Gm-Features: AVHnY4I2CJoGV0L82XUkZ4Qs2Y82u6zDH_dLNq4pI6JHK5dBaD_MkAzrjnZOUF4 Message-ID: Subject: Re: effective_wal_level is not decreasing after using REPACK (CONCURRENTLY) To: Masahiko Sawada Cc: Imran Zaheer , 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 Fri, May 22, 2026 at 11:40=E2=80=AFAM Masahiko Sawada wrote: > > On Thu, May 21, 2026 at 9:19=E2=80=AFPM shveta malik wrote: > > > > 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 does= n'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 i= s > > > 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.. > > > > > Good catch! > > > > > 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 = would > > 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 i= s the > > right direction. Thoughts? > > Good point. I think we can have ReplicationSlotDropAcquired() have a > flag to skip sending a deactivation request. That way, > ReplicationSlotsDropDBSlots() can check the logical slot presence > after processing all slots and other callers can request the > deactivation after dropping the slot. It would help simplify the code > somewhat. It's conventional that when dropping a slot we acquire the > slot first and call RepicationSlotDropAcquired() to reliably drop a > slot (ReplicationSlotCleanup() is an exception). Therefore, I think > that having a flag to ReplicationSlotDropAcquired() could help future > developers to make sure to disable logical decoding at the slot drop. > Yes, that seems like a good proposal. Having an explicit argument would require authors to consciously review and decide whether logical decoding should be disabled based on their specific use case. That would help prevent such bugs from being introduced unintentionally. thanks Shveta