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 1w4opE-002aVI-2P for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Mar 2026 23:36:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w4opD-0034PK-0c for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Mar 2026 23:36:47 +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 1w4opC-0034Os-2r for pgsql-hackers@lists.postgresql.org; Mon, 23 Mar 2026 23:36:47 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w4opA-00000000mWM-1ktm for pgsql-hackers@postgresql.org; Mon, 23 Mar 2026 23:36:47 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-5a0ff30b240so4916684e87.0 for ; Mon, 23 Mar 2026 16:36:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774309004; cv=none; d=google.com; s=arc-20240605; b=Up3g9f5grW5foaUZ/5bJWIlbeyJzmF5/dCBgI4dNDTRInx67c8VwQTKQ5Bl/Pu4gjU Pd7vAbPgSm5rurBsVh5FgODj4gOWDzcFmTlyptVejQR9+Fj1mfuI35HU8UjXaeNxvR1F IRovobtvFjaB6mvF0RQqdgxi7C/zmO8QBoeSDpqu7E9YNcFBrhd9oxFQ5d8cblfVTP0f IFeqqafXuRMu+tddRP9w+FBBE+zLHbCMbcdzUi1IMnuUs0bTl0MNGJjQlP/fD4CcDUFy ImkLTKwIrwYDIgwnyammUnJNzgUuvo1XoRPRd8bvtvdxqbssS77Sr83b/MyR2QyBzL5b kW3g== 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=Gg0kwr5jDjFS9f94g9k3Go8bhVlwCdUQEZI23gTrDbk=; fh=PtQjzUeyBPVP8PgJVA/ab6Hk9/BbuqqaMhAQ7tT5j64=; b=cwoaPigF6S/GVH/9cCVaahl71Z6XYXN8bIsBI1yF5H+V8hIOIkrE24NSTkce5mqQfq lcBlUftp0UPYTjIrZrMxaEUFmT5b5BKTERo4fw/Ji0R1ABTkTbg80532oH39bnPFZHHA FSdRXdkGlXdOUz8JqMMk+XBRSUAM2uk3VmpZIso1P65bkT4D8ZlGyC0xAQsXRiq0Uf1m sipcxZfZGuoK+MmAYKAXy+clMH6273Y0UEJUi3Bj/E2PPL8A1C27fTq5S06rUeV5svhw wPF7YqS/hKzVI0OXVNVm1ef9itBFaC0yXHkdev17+QMJs4D0dOWXPImOvRoK6GLsoelw 8HiQ==; 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=1774309004; x=1774913804; 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=Gg0kwr5jDjFS9f94g9k3Go8bhVlwCdUQEZI23gTrDbk=; b=T/sT6zooZFCMp64DjmedZkKxisNhyFnXdX5J+1VNu4xW5snsqkFYGwvs9YM6dUn3/y ER+Ur5O8oBCDyDsjVwLi+vYygzVuSyvaPDkWVjB8g+szHRXt/3LegxkJICgifEIF9mgN dAQ4vyEYN2SsGNrh89FIeu5nKfoL+9rWWLbw9qUc43GIaGLdHh2NyZ2lEfQbzrjcSW1G OzjM6VK7WgU5o8SpYMp62ry2Y6cxAk6zD1eFSjIiYmKW0UcbFMcV6Gw4TU2RFroZWYIT k/hKqnpu6g3pjAEHEJ9DHUF+ekQk2PyAKtqXPAys5Q0lmlDnUcUOJE57g4b0fbh60U5Q Sq3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774309004; x=1774913804; 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=Gg0kwr5jDjFS9f94g9k3Go8bhVlwCdUQEZI23gTrDbk=; b=EWUuu2OJ4C4WgBRc2lL1C7wv7wAI5Bvpn834gEIvTZgAmuwLAX7HdSzdCJZsbpuqyL ZhBrtcG1tGUsOniiV/pPzxKXYrl/1wGUCRXyguZYQ0IMRjv+CBJnLljWAeVFula8E+CC TdDKWq/eOT2g/UxIe/xOOvLqtMhaV2uxdRPIybyHCPFuys7moJhF1er/8cYfa9pLNUyr yftkmCYNhC3tLJGNkle9rEz8bC6pc5Jl5EGlPFtInxLgIdqpumjMtXomGyhuehIAta44 njO6CkYcXD4jliEjETdKnG9lYpudZOTRmoCmnjEv7Iy0ZVnrMlp1oFRgsdd5qVvYIAP2 C5QA== X-Forwarded-Encrypted: i=1; AJvYcCVd7npxuEuuodAph9wrjWJdfG55nARD2L3tcEP0qalqepmC8QGReRiN/i1wHM6Cc0eN9lr/K9UrTGiiObAu@postgresql.org X-Gm-Message-State: AOJu0Yyxl3rckoaJ9gcBh175mBncMzqRrBZvVQcKBxC6rBvywGtqCqCy TpkQ7+1LhmuzpwVEkJTNkmjtmxWVBqb7iWti6nzziXhfsz0zjsByknJqapjz4+gF8lGfgUwymGY NCD6DaQdHDcbz17Cixi3ZkFqsvzDi16U= X-Gm-Gg: ATEYQzy62+wqVul7kWY2H2RRNvqIA7/miTDGz/9fCGqaCsHBSlK0LtTO+qHZSya6T5e sw/lbdZPEpmHlz3MslsoCW49jjwzOTzobbKsVQhXvJ5uq/aEwSzcVsdt5bSGhd0wpQoj+PPq8ZN A1do804rB2ZwPAsfsKJGucH1v4gUxUib+LXARWcfitxh0niKUR9DNlmCOlSBHFlMFHqfw7K1uR9 vUEIytIlFrL2AmL+otOcgGkqD4k5RNGH3QhwvXDApPfYXNweaNPhmxfcouvfHCJBZqOJDfeZCmr Bf5bg/ee X-Received: by 2002:a05:6512:3f15:b0:5a1:3134:9bac with SMTP id 2adb3069b0e04-5a285b442aemr4682131e87.28.1774309003639; Mon, 23 Mar 2026 16:36:43 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Masahiko Sawada Date: Mon, 23 Mar 2026 16:36:07 -0700 X-Gm-Features: AaiRm53iFq5f29Eyf0xq84dh0ePFReJ63DS37h_QDQPE6-UnPY22ZqtENo1StMU Message-ID: Subject: Re: Introduce XID age based replication slot invalidation To: Bharath Rupireddy Cc: SATYANARAYANA NARLAPURAM , "Hayato Kuroda (Fujitsu)" , John H , PostgreSQL-development 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, On Mon, Mar 23, 2026 at 9:00=E2=80=AFAM Bharath Rupireddy wrote: > > Hi, > > On Fri, Mar 20, 2026 at 11:29=E2=80=AFPM SATYANARAYANA NARLAPURAM > wrote: > > > > Do you think we need different GUCs for catalog_xmin and xmin? If table= bloat is a concern (not catalog bloat), then logical slots are not require= d to invalidate unless the cluster is close to wraparound. > > IMO the main purpose of max_slot_xid_age is to prevent XID wraparound. > For bloat, I still think max_slot_wal_keep_size is the better choice. > > Where max_slot_xid_age is really useful is when the vacuum can't > freeze because a replication slot (physical or logical) is holding > back the XID horizon and the system is getting close to wraparound. > Invalidating such a slot clears the way for vacuum. Setting > max_slot_xid_age above vacuum_failsafe_age allows vacuum to waste > cycles scanning tables it cannot freeze. Keeping max_slot_xid_age <=3D > vacuum_failsafe_age (default 1.6B) prevents this by invalidating the > slot before vacuum effort is wasted. > > As far as XID wraparound is concerned, both xmin and catalog_xmin need > to be treated similarly. Either one can hold back freezing and push > the system toward wraparound. So I don't think we need separate GUCs > for xmin and catalog_xmin unless I'm missing something. One GUC > covering both keeps things simple. I've studied the discussion on this thread and the patch. I understand the purpose of this feature and agree that it's useful especially in cases where orphaned (physical or logical) replication slots prevent the xmin from advancing and inactive_since based slot invalidation might not fit. And +1 for treating both the slot's xmin and catalog_xmin similarly with the single GUC. > >> I made the following design choice: try invalidating only once per > >> vacuum cycle, not per table. While this keeps the cost of checking > >> (incl. the XidGenLock contention) for invalidation to a minimum when > >> there are a large number of tables and replication slots, it can be > >> less effective when individual tables/indexes are large. Invalidating > >> during checkpoints can help to some extent with the large table/index > >> cases. But I'm open to thoughts on this. > > > > It may not solve the intent when the vacuum cycle is longer, which one = can expect on a large database particularly when there is heavy bloat. > > This design choice boils down to the following: a database instance > having either 1/ a large number of small tables or 2/ large tables. > From my experience, I have seen both cases but mostly case 2 (others > can correct me). In this context, having an XID age based slot > invalidation check once per relation makes sense. However, I'm open to > more thoughts here. ISTM that checking the XID-based slot invalidation per table would be more bullet-proof and cover many cases. How about checking the XID-based slot invalidation opportunity only when the OldestXmin is older than the new GUC? For example, we can do this check in heap_vacuum_rel() based on the VacuumCutoffs returned by vacuum_get_cutoffs(). If we invalidate at least one slot for its XID, we can re-compute the OldestXmin. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com