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 1wHIZz-0072Ra-0W for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Apr 2026 09:48:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wHIZy-00DJpp-0L for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Apr 2026 09:48:38 +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 1wHIZx-00DJpg-2e for pgsql-hackers@lists.postgresql.org; Mon, 27 Apr 2026 09:48:37 +0000 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wHIZv-000000030Z2-38YG for pgsql-hackers@lists.postgresql.org; Mon, 27 Apr 2026 09:48:36 +0000 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-c76b9efc299so4053480a12.0 for ; Mon, 27 Apr 2026 02:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777283315; cv=none; d=google.com; s=arc-20240605; b=GX0IOQD+Wd8aoP+TE79HHrgn3FZJoXxkaXxckWgFO/fCR/LED1U1ZGnbbiSSCojjcm +7JCXuK/h7P98sesP1OUMvI9wYVvmvpQQ5CJsVKiniFvf1vxEiNtm6smOP1Z/BoHRWYY K6565TI8bPp5rWT9JRoBGtGAz4rejEhsTYD8dilfkHeiRr8V4LkF67oHMNa58faQ/d9A wGAJwiS/aRPAz3wlHsJhhc4wCMqwbWWRUpXCQUgJsW06Ok/u+1jSTAekY+SAi08Z95qg enhIpHZomrAX74fZJZAPKEXFYf4wxgF2mM/kHZ2MKpUB4MDNEHMtfOt9838+4WPUQOLn YwSg== 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=0RORj0hx/hVGGDo3M0QqMVXDjLhF/FBBVZzCnWkXmgA=; fh=fywpbSg23TiAXCMdVzGUAfK5nB+ZMkbWf29qXd8U6Ow=; b=gCypug8AOG5TeqzRvmlpDN/8Z6wxrfj2IG/5bMUwPjVlCLafNw4JeqKdwTvBGdG+kq QP9vhfIapC+FGDWfgID/QF8LclvdV8qXJWpcDIvb8PcVKkHDSjjwm9riC+l76BI4AAAb J7CRLwg7+TVvrUg3SOD0KlG6ci0oMqgxsuvw3at9W0X6/WLktUcTwXQlfNKVu16bcVIV pqlyBhrYwOkYO5O3BKvKYjr4CJwhFkayw2Kz+6YCtPz3/J1SMTS6ve3iEvrdZ0/Xjx53 MNKu7VXdxOKpJsF4y2l6GWaaw7vpEmSCzJ6jMWDUuWwwVC0mFUSpZivW+d5gCIVYqUoF sYoQ==; darn=lists.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=1777283315; x=1777888115; darn=lists.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=0RORj0hx/hVGGDo3M0QqMVXDjLhF/FBBVZzCnWkXmgA=; b=TbN+L69/1fRdFlsDMuSbr5gRnL2tA48x7gbOAjFR1n4g+hyjn7JeZLzMdThBW9Pgvg EqePiIeJaK9DFYWfzC8vvvk7OpwLLig/ToHZHpmCl5zS5MQ04+gF8qAWJL28wd+cAeom HcELdOoF9Iai2FyCr//JMvknla3GjxHHJ01BcKxIXyS8Q/U4X2DnczUuJcJWbvyu0np3 ZUzFAUFVs7kbQgbY5k4tEqGzbXO/YTzXCvRv8ZiZyHUGpODe0oxWRfCVDB+Bn/AMoxWq xYFfjgeeeJghGwmWQdbHcdXpdOqulj61Nj4nVPcFjsaY1FhjbxhevVB6TtbSGpRcLOD6 Vkyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777283315; x=1777888115; 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=0RORj0hx/hVGGDo3M0QqMVXDjLhF/FBBVZzCnWkXmgA=; b=EKo1sql//21IkompqRqNiM1bqZHvBduLrPom/YLZ7cR1YrK8j1fOa/g/imcBc6VOY7 aArl8AaLFUAzlQiVgM8pZs2iDiLoOORFtxa42xF9hfiGzwwS6EwUQoH2GbJ3PnYEUBnh QLKW9LNSnzPYRxoT370WBQn1djXsGGuxSR0TZczGEoZPlJAf506/iBUQ3EJaVw/HjmTB nHWkFZP82IbKKoHkdUsbimawvvDmGyIRb5sjocMKkd2ARaHCw9WhIpRS7AsyNYMZ+SDl 7zfstH8Of1WvbsEKJEx4kdnXfhNkWUgzQhtPLgElcA8JGXv3KIljZ+6+fF0jmfjBQ0+S C/tg== X-Gm-Message-State: AOJu0Yw7ZHx0X3eoNXt8FpEYxCx86M67BoZGWs1MBGL3uMdXDKGQk497 jch0LhW024zIwXkg0NT7sCfqy9hr/n/y0nsnVyc80slJCTS1betuu2ir/gY7yjUg5IZ9eZmmYn6 f+GUBsAoWlvrptvm3kEz2EyQV4OuELhM= X-Gm-Gg: AeBDievhtUyUy4yqLxbq29AEI3BaJyYvVh5sdevnUvzFXgKtPgXms7Z93Reuah/A7LV IFeAB23XE8ySoVrePN76cj6tB3zVg8qqWnXdggDF4JKgMFOZ9Rl3DimwIKyRdzEsmCF3tZ0fB++ HFI8amZ0LzRcGFw8EbMMEXmrFOuK8kIVRESyUhQfVmNzJ0rD5B19UWFIraGKZk8qp+8GSQxfjdE dcpVxcwOas5XvGRGhQ57ed2PidHC6GocW2oGkRonIS0ZTbl9FEOjMH27cn2HI8ws9345Ad7YAyZ Aq+rCv68tzfZbrpnR+4UIfd7F2gChp7w8M6sCMXQlivr/bhRrQSvnL07Uzyl4qYi X-Received: by 2002:a05:6a21:3399:b0:395:7fb:9362 with SMTP id adf61e73a8af0-3a08d74077cmr48165285637.19.1777283315153; Mon, 27 Apr 2026 02:48:35 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Mon, 27 Apr 2026 15:18:23 +0530 X-Gm-Features: AVHnY4K0oVPK7stiQkq8gO0kKZmt5LnERYVHW7B6DR85BH_a2GENXAzizxJKrr0 Message-ID: Subject: Re: [Patch]: Fix excessive ProcArrayLock acquisitions with subscription max_retention_duration=0 To: SATYANARAYANA NARLAPURAM Cc: PostgreSQL Hackers , Amit Kapila , 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 Mon, Apr 27, 2026 at 2:11=E2=80=AFPM SATYANARAYANA NARLAPURAM wrote: > > Hi Hackers, > > When a subscription has retain_dead_tuples enabled with maxretention set > to zero (unlimited retention), adjust_xid_advance_interval() caps > xid_advance_interval to Min(interval, maxretention). Since maxretention > is zero, this always collapses the interval to zero milliseconds. > > A zero makes TimestampDifferenceExceeds(last_time, now, 0) always > true in get_candidate_xid(). This causes the apply worker to call > GetOldestActiveTransactionId() on every single WAL message. This results = in > a huge number of ProcArrayLock acquisitions under moderate write load. > > Fix by adding a maxretention > 0 guard to the cap. When maxretention is z= ero , > the exponential back-off in adjust_xid_advance_interval() > now works correctly, growing the interval from 100 ms toward the 180 s > ceiling. > > Measured with perf uprobe counting GetOldestActiveTransactionId calls > at ~39K TPS (pgbench, 5 clients): > > Before fix: 25,104 calls / 5 s (~5,021/s) > After fix: 31 calls / 5 s (~6/s) > Thanks for reporting it. I am reveiwing the problem sattement. Meanwhile can you please look at it, I am getting the following error while applying the patch on my Ubuntu setup (git am): error: corrupt patch at line 22 thanks Shveta