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 1wHg9O-007PTb-09 for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Apr 2026 10:58:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wHg9N-00H17Q-0l for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Apr 2026 10:58:45 +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 1wHg9M-00H179-36 for pgsql-hackers@lists.postgresql.org; Tue, 28 Apr 2026 10:58:44 +0000 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wHg9L-00000003VhP-04LY for pgsql-hackers@lists.postgresql.org; Tue, 28 Apr 2026 10:58:44 +0000 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-38e800deae4so97614811fa.0 for ; Tue, 28 Apr 2026 03:58:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777373922; cv=none; d=google.com; s=arc-20240605; b=Gm4VQ2nh9nMjQUZ3g4U6/GD5DcVXtRCZ2IQnjZI8T78ncg24a7qZCrMf0LlVeXb6mv X5UARupUFSjezK0+hlqcMpT/Nr82Q0NNi+nhwWIEqNZ0JacI6v8UBpWEC9dMycBfQcE0 8MigrImsjsGcy5Wls3zK/5Iqk/ptrfbV9kLxuF9AEBBRWZ4PRyNR2QBsA15y3FccIeDO FYTrM70lEMYzwUbWbKkv3BvChQI6J5E8fyWRLfJkUIYxfIA6RyjjZbo1wynp6kFDOQSL 27cpf10H3TvPzeGmy9CYZOyxmAeK/TFaQmRiapyzVZbtaiazLiW/QilLP/Thfzj6WzIG ePrA== 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=EgknNiqNmkEZ5nwZf//gx9jHnxKY+XW/s3TKlxpLV+Q=; fh=9OyL1yYAb5AwJjZp4LMad8DPMO6pPa1GpjRrEGrp3bk=; b=IO0znSXE8TpXfrCTTtWiE5QGOCFD56bOeBpPR1gfOFvLWeREoEM1f6Bm8ZntsDE4s3 MWlVUYx9i7bjmDd103jQQf6Ah8u36PASCkbqg+1AdtTVBHO+/Im1d2Q1XO0FIx4kY/+c UZxudUvb4PYHyte7EFvQTtm9BrDUMh0dpFRBaxiOt0PaZxMGLpLb6IiNsmLuAmFVND3X xUWvHZzYYXRzTQcldVtgiNzBDqrqjj14Z7kVJK3Q2u7yuQWIj4ti1FgX7hNlZN7FujoK TMiKmcUFG6R05VdZmVfg+258Qu8m44ULN0z55lPe0FR/rT3R9vr+wn2RG57kqZiwxlny 3bNw==; 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=1777373922; x=1777978722; 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=EgknNiqNmkEZ5nwZf//gx9jHnxKY+XW/s3TKlxpLV+Q=; b=cIo32qjYCWNpBmhfXpSA5oHjFmWr26H4XS9r1wjqctFv8AmryjGHLj1tVOhX/3Q9Jp Ktz03/0IUqPDZYZeVeLhTfuiP1F7jHTX8JyMc6iQ5d94eiy9zCSsGOGWOaRdLuMrT9IW BANHeCUfG87rZl6JnEtYwDYcj6bDc7Eamx5k9ZJO/AuPWtIzke2Ae3jUE8qDyAkp3/O6 bd7mj97jZh3cZyOlY8dYvZAfvuNavA9Fafd8aerrHle7ion93UuUH1KP68g7RMZcqViO Vud9z5LkZLvRFg4KEVuBWPnKPZoX4QsWP6IsNePZISAxbKiulQb/y96qQR76KV/wvnds 787w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777373922; x=1777978722; 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=EgknNiqNmkEZ5nwZf//gx9jHnxKY+XW/s3TKlxpLV+Q=; b=Vit6n6RN4auLyYP57SD8+2S0HS7l2k/pOxTnuVHx/DysfaHe/QHn8YY8ACXSDylL1t /aJ1/iCBVtQGscjbHUyCbRSisSInPGHVGR9HDwGJuL8EElyKuiUavMKYwlTTYKYKkZCH S4GGk7tGkUnFZNSAxnFhuZm8sxc6Bh1aQz2yjTThP8W5OBSdrgrRqg52fYlyed9fX1In v6u9Cn0Pfv0KnwaoR39xClLfuRf+4jK9pWXEIOduEmABSDSCjakcUYUEQS/kWNkXs7tE DeVJ3tFvIUu6w0zLwwjf0kXBb2VMhkd6MAHSZ2dqX81uLl6xc7Dl7xuYibyy6fNr/Knz wu7Q== X-Forwarded-Encrypted: i=1; AFNElJ/2ekbB6YAvpl95C89FdW5lkY3xaE+AAByfQFNXmPJhFHxhPKAHzy6eQWtTEKpQLIio1y4iMzaZMqIr8+JK@lists.postgresql.org X-Gm-Message-State: AOJu0YzlXciOpAPjAXcfUDQheU8TAIdcAxqkfLR/TUqj3gdmsvUXJelc FnszcJdFfyDxa7rv23KPTUWYxrsDr0RpvOGrBwRV766DhKABBHX53RWfppQ+i8Scrbvl8TUcCjw mElkSq25sI4ji/e67jclY1/AqfPW8Ww0KJE3R4gs= X-Gm-Gg: AeBDievAf+H6q0C5xImaz2JuxRtMLxEIX1kwmmRF/ur79owQIgLPut4qsijRvgkBUVL MNqUC5zKT81cId529sC3e/jjBaY5dsAfqWV7Ir29jR3WsHlv7uTGphi1YyESa9A1pXFwqHM3iSm Zm7ymbNyobeFs70hjtyMVjbRUgvo6LMG96cpJIdCayByUaqS0IUJ8Sb6z/Qry7qwZyr+dR//H7L RP3s0QL/CIRwvZQkgxP2VGfTL9Rwr8OIZ4nZSd30VVOY5SBHg9vNbvlGfjQIGnDxCWvM3vbBi6Q 8n4nHVvCxKncQGIrr5A6lcjvm9++itw26lAq4rYfRcIb3SPSk1E= X-Received: by 2002:a05:651c:2118:b0:391:a48:a4a2 with SMTP id 38308e7fff4ca-39240d09571mr9153421fa.10.1777373921952; Tue, 28 Apr 2026 03:58:41 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Tue, 28 Apr 2026 16:28:29 +0530 X-Gm-Features: AVHnY4JwN7PpjJS0r8Of2ddhk7a5INZ4svAAndGgLhDzmaXelqRiKFFE_5XYF3s Message-ID: Subject: Re: [Patch]: Fix excessive ProcArrayLock acquisitions with subscription max_retention_duration=0 To: shveta malik Cc: SATYANARAYANA NARLAPURAM , PostgreSQL Hackers 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 Tue, Apr 28, 2026 at 9:38=E2=80=AFAM shveta malik wrote: > > 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= set > >> > to zero (unlimited retention), adjust_xid_advance_interval() caps > >> > xid_advance_interval to Min(interval, maxretention). Since maxreten= tion > >> > 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 res= ults in > >> > a huge number of ProcArrayLock acquisitions under moderate write loa= d. > >> > > >> > Fix by adding a maxretention > 0 guard to the cap. When maxretention= is 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 call= s > >> > 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. The patch looks good. > LGTM as well, so pushed. --=20 With Regards, Amit Kapila.