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 1wHduN-007Ngp-1w for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Apr 2026 08:35:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wHdtN-00GlnI-1G for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Apr 2026 08:34:05 +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 1wHdtN-00Gln9-0K for pgsql-hackers@lists.postgresql.org; Tue, 28 Apr 2026 08:34:05 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wHdtL-00000003A5C-0HdA for pgsql-hackers@lists.postgresql.org; Tue, 28 Apr 2026 08:34:04 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-59dea72099eso12475099e87.0 for ; Tue, 28 Apr 2026 01:34:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777365240; cv=none; d=google.com; s=arc-20240605; b=T8vaKmi07rs4l3VxPUrQIG/ZY717dw4c9hss9xmKFperM+nxC5z29pn6P9vrmlYLXz r02hGi3HIE82/l6tgcYFFRFKuiLyHZxLzcuqdC/ycQmi3eo0ZKln4H6B/5TUY+olPZcF f2TPmH6R2T7CSVtFicUMcTYTHdtkHPnNeQ4eC2V3KUDd4aTOdfdeg4LRuFmGQ7qfdJB4 GRgM2vzd0jD+LOKfBdc5xT0e3a3pVaVxSsvx5BE4GeWJrvgQwef6BirHyClHNcNnm4+S WsceBlPiUWfAMZgx+cEXe5+UaoRbn8lrMWxmPpgjrix+ln0CCGNklyXuQdG8ittKBOo1 Be7A== 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=Bjtipd8UhnsKSws05pJ9asWRXmc8RGoFqUO5BkSIAhE=; fh=o7pnJqfUM0iKlA2w/pwtY/Ego0u38LZmfAjcvZBDQjk=; b=O8tms6SQqdBZ4SS3kwag/tVKfigMuXIFeEeRV/n948CnBZYM/KpSasCA/i3CZx2lgI Str/ngG3mCrT1+p5YDQVzLc6h8tscVkfMbvzyCHXyk9Wzdt4JCpIzoQ0HYSFBF9ra0oz cAZr7Uyy8JMlvRAExkVYgfJnOWMdGF/hQQH5TVVbLGL5q86Fich1SnJOsJV5Z3cFrgF6 lGu0KFfHeDtib/cOFURZCeQg2u9aCgydCoOF1Ir4m/dOqnTv0eTZ2IMN+FR8ks/AqhWW Oau1KjntqzXQl4ynLO8tqzDZk/w7goqnldwuFblscr7FO65UTpdFmLPv+DHnML9tVHTr nilA==; 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=1777365240; x=1777970040; 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=Bjtipd8UhnsKSws05pJ9asWRXmc8RGoFqUO5BkSIAhE=; b=ZWGfChHj4lOU5FnabYpn2JqTmJokY4X4aabn7T8fL/NdEM4bj8By3h49tFelLW8I/B wuwJpPtPY/iWcq/qkdFt5ni1tSx2UoCCP/jOmTuKUphqqdRET/ejfZErKsbhnPZluZvh a3/scfFJiLJc9b1ROOpAY9x5KgxSF1t5EFZiU9conef5JZqFyA9lAWhl1ERL8y/5OfH7 0DAwqOvbvinv7Fj0E9T0Hc41/WE8Dus+uC8FRH1JeJjwSquX7EiUFUK76wUupUCAJrQC 6sJlTxxk+8H8LVufbPkXCMbFHkxszbP5Mxn5B+cFruhLV1orYmDbRUhn8FLxk1+tXPga 7tPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777365240; x=1777970040; 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=Bjtipd8UhnsKSws05pJ9asWRXmc8RGoFqUO5BkSIAhE=; b=dFqJtjUlHJy9fWojqJLZMHUV8wFbmCOTvr5sNXVHcchMVm3toYtiZKwTSm8ZnZ/pmh 7MilyoorPkeIGS9hc27VFZBE5Dl7kyoH6Ac4EbRZqNgZnliL15xFEtPeXwrVjIjU10pa vbIAr8rKINvNcqohqjbSUrETdifRPkbdvgXMwu20E9Cn2vnNNqNYA2hk2dDuQddH3EXL QPlsiUSzHfX4dxI8RdSFUs6y03k7u3FAjmVAaJKJMrzkd/vLf90g1kPegCdOeDXVZovm 65fWQPSTSPBOkpJFsObPtHFL9uFSrGQpAw1UApzMTCDNdvQZbUD6ZnjxdECh9R7LUbwB 9NjQ== X-Forwarded-Encrypted: i=1; AFNElJ8gkoIInJ6TuOa5kl+VxNw/gTXPOcAtne1kU9gAPPtO0KEkjpt1LrBc3jUkLKMSFbgQ5ls2qL6ACEZyzRqU@lists.postgresql.org X-Gm-Message-State: AOJu0Yw7baWs1adsZVn1CWWD07orgxAIOstX89tbe05nGh83/otx6l57 HycK4PhmI1egIRJbCBWrQd4O/uels58vb+pOocYNr4MCsCs8crMlCUS88S9AbsA/iV21IdGKvvS qOJDFTJUYe5WWU9g4awhiST+rSVGRuA== X-Gm-Gg: AeBDietzyHSi+ZIx5nMYRIgecHwvy7AxJ2MCi3g4XTHxbur/fkwrsoGfqf/56yvh41m w0cn+6jyC5gpdr2k/BGQpGENaxmVJ2Ce4vw02HE/YAYgTOfxaOcZIooAtI79z8tVv5EQHzAZJke bTx4BeaWN8QIT3wFOjFwxMjnMiBVzPRJRDV5EOS63xnkSRgEq3/oypMG/cb4YurXcYuRcLKEE8Z BGqwSFZAzWakWtMsOmWOXOtfFXfyfw/7ejH1N5aMQHPVPNcRi5gvusQ/E4sr2PRDI44fPmDiYIK MclEnKB0+xt3DHatI8O95Ns8LgyHydLZDJOLvkvOa52TMGu32A== X-Received: by 2002:a05:6512:318e:b0:5a3:7525:2b29 with SMTP id 2adb3069b0e04-5a74662e691mr744854e87.39.1777365240143; Tue, 28 Apr 2026 01:34:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Nisha Moond Date: Tue, 28 Apr 2026 14:03:48 +0530 X-Gm-Features: AVHnY4IhJz8o_Ut0WVdoQWxATw3IhWvHLB9YPSYBXvJEiqj9Sbv5kHckQqlvvW8 Message-ID: Subject: Re: [Patch]: Fix excessive ProcArrayLock acquisitions with subscription max_retention_duration=0 To: SATYANARAYANA NARLAPURAM Cc: shveta malik , PostgreSQL Hackers , Amit Kapila 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 10:32=E2=80=AFPM SATYANARAYANA NARLAPURAM wrote: > > Hi, > > On Mon, Apr 27, 2026 at 2:48=E2=80=AFAM shveta malik wrote: >> >> 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 s= et >> > to zero (unlimited retention), adjust_xid_advance_interval() caps >> > xid_advance_interval to Min(interval, maxretention). Since maxretenti= on >> > 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 resul= ts in >> > a huge number of ProcArrayLock acquisitions under moderate write load. >> > >> > Fix by adding a maxretention > 0 guard to the cap. When maxretention i= s zero , >> > 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! Please find the updated v2 patch. Thanks for the patch. I am able to reproduce the reported issue in debugging. The xid_advance_interval stays 0 when retain_dead_tuples is enabled but max_retention_duration is off which is unexpected behavior. Confirmed that the patch fixed it. -- Thanks, Nisha