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.94.2) (envelope-from ) id 1uw44W-005bEx-Kl for pgsql-general@arkaria.postgresql.org; Tue, 09 Sep 2025 19:32:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uw44V-00EAUr-G6 for pgsql-general@arkaria.postgresql.org; Tue, 09 Sep 2025 19:32:07 +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.94.2) (envelope-from ) id 1uw44V-00EAUi-3t for pgsql-general@lists.postgresql.org; Tue, 09 Sep 2025 19:32:07 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uw44R-001ZnE-2a for pgsql-general@postgresql.org; Tue, 09 Sep 2025 19:32:06 +0000 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-624fdf51b44so3862895a12.1 for ; Tue, 09 Sep 2025 12:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757446323; x=1758051123; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=vMX47JXiJfyJCfjSF5hmObD4AO7HFj7kur1Q/ObCCcU=; b=XvBUbThWl8lABaDX6uj8LL6ZDpawEJJAL4mSwg9au+C5TAuJqdPnSfjW56ultFVhNz 57nJ6FOGg3Ko8WiRfWM9d4C9i+ERd0+LcXJOME5tBMa4T2DqUutr/YfUy8s6hqGl2aso S93SEjC7WCkwWLVRrAiaX1n2LZ5tHipVdKVitIWAfgt3f00KgZIQAxcDo+GfjaBSNjmn w3sLYC/Z4CXyObdxylWzO7XCtABXvGeqUtXo7JG89xV9e96a1NAdd4V0CGl+0JIKjzBR OchjxTfrTNLNmZ/kr3GvGHzrT8z5RQCM61Aus78DH7vnuK4/agCAPlryonw8JC4lsmKk 9ZAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757446323; x=1758051123; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vMX47JXiJfyJCfjSF5hmObD4AO7HFj7kur1Q/ObCCcU=; b=jHt544YCfyKRDYPkIIPJ+VldZp0wtH+CZ2xoCzy66TnS+RStrB/7xEEu5EB4Jct/Kc 9dDGAmTX9RSY9scxyHi5FjRGrPiVtJR0EIy+sfBCMb6XjoGdD6KfVGdqPA57zlyRmFPE kIUpSmLJWA2BHO1C5LWThXAGhwZ7K8rW7jnj+4UxwYdoHYJpaK+hbRfDC1jkR2MljJZJ ALBeP0ioMTh2JdWrTh9WR5HhpzDRGP+creqmCyQ8+JPM6PmpPFh+RBwopv6Cs26322II ytx2CB+yCQ302QYe5gLy4OFVJrTCle8U+xWh5OiDCNYURrGNa8R7hTbMHd3OTTL1viv6 7sOw== X-Gm-Message-State: AOJu0YxoG2C2xEKGmfQvjsRcNhMG709DPASc83f+pTSwUsexLFWzyzls kag+G7QQ/OVyKuoUUzdKejj2F5drMXyflS2rRTzQvxiSseaTE9quLlLMLBRi03A07gXQbeO5l8x kcCxdzl1RkDFpdqKbEwErfXqPKSLfwdU= X-Gm-Gg: ASbGncu3GLPb/XO7HymXrTJF2fccNz8ZAga+NOaPupQzqp+sWRYp6filniuGYFDnvQt vyDfYPXIrEKYhuXN04ZWOr0D1TwEvpndwRxgS9FyzvMTs3RYUnfIAI/xz3p0WEtDSzKW08q0Hse jWl6+4LISXRsBib0Broj/2Ptt9aLzb1pCPDdgHfSMx4BR8xmkrOvFndskQmGeoByeSluA0kPqw/ 2HQ9hhBEA== X-Google-Smtp-Source: AGHT+IHCtHouBRpyF9zL9SrIkqZ9QZT/ZcU/i1xLzKC5qSncYtAblgNBr+rw/w6e9hoCXWyCz9uqbas0F6RtxvfEkWc= X-Received: by 2002:a05:6402:34d0:b0:621:7d0a:150c with SMTP id 4fb4d7f45d1cf-6237b875737mr11618398a12.28.1757446323216; Tue, 09 Sep 2025 12:32:03 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Justin Date: Tue, 9 Sep 2025 15:31:51 -0400 X-Gm-Features: AS18NWCnQkD171OPDyVOnERKNiQaw5gcDqCWPM8iRvOxeROylwWQKNJGFzAkfrY Message-ID: Subject: Re: LWLock SerializableFinishedList To: Alec Cozens Cc: "pgsql-general@postgresql.org" Content-Type: multipart/alternative; boundary="000000000000cea489063e635bb4" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000cea489063e635bb4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Sep 8, 2025 at 12:04=E2=80=AFPM Alec Cozens wrote: > Looking at the postgresql code, the LW lock SerializableFinishedList > appears to be acquired and then released, usually in the duration of a ca= ll > to a procedure. Base on that (admittedly maybe faulty) view of the code, = I > am surprised to see the lock held open for over and hour and a half. > > > > > Hi Alec, Clarification Lock_timeout and Statement_timeout work the same way, they just differ in what triggers them. Lock timeout is triggered when a lock can not be acquired in the specified time throwing an error. Statement_Timeout is triggered when any specific command/query can not be executed in the specific time. the error message could not truncate directory "pg_serial": apparent wraparound This is concerning: do you have any replicas?? There is a known issue when hot_standby_feedback =3D on and replica has long running transaction running, SLRU will overflow causing PostgreSQL to go to a crawl. Only after the replica releases whatever locks it has does performance return to normal. This has been mitigated in PostgreSQL 17 with these configurable settings https://www.postgresql.org/docs/devel/runtime-config-resource.html#GUC-MULT= IXACT-MEMBER-BUFFERS I have no idea if SLRU directly affects serialized transactions, I would suspect that it does as SLRU affects all transactions and if it overflows bad things start happening. The next time this happen look at the replica to see if there are any long running transactions All the conditions I can think of that can cause this is a transaction sitting out there holding onto an XID causing the serialized transactions to wait Thank you Justin --000000000000cea489063e635bb4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Mon, Sep 8, 2025= at 12:04=E2=80=AFPM Alec Cozens <acozens@pixelpower.com> wrote:

Looking at the postgresql code, the LW lock SerializableFinishedList appears to be acquired and then released, u= sually in the duration of a call to a procedure. Base on that (admittedly m= aybe faulty) view of the code, I am surprised to see the lock held open for= over and hour and a half.

=C2=A0


<= div>
Hi Alec,

Clarification=C2=A0 Lock_timeout and Sta= tement_timeout work the same way, they just differ in=C2=A0what triggers th= em.=C2=A0 Lock timeout is triggered when a lock can not be acquired in the = specified=C2=A0time throwing an error. Statement_Timeout is triggered when = any specific command/query can not be executed in the specific time.=C2=A0= =C2=A0

the error message=C2=A0

could not truncate directory "pg_serial": apparent wrap= around

This is concerning:=C2=A0 do you have any replicas??= =C2=A0 There=C2=A0 is a known issue=C2=A0 when hot_standby_feedback =3D on = and replica has long running transaction running, SLRU will overflow causin= g PostgreSQL to go to a crawl. Only after the replica releases whatever=C2= =A0locks it has does performance return to normal.=C2=A0 This has been miti= gated in PostgreSQL 17 with these configurable settings=C2=A0
https://www.postgresql.org/docs/devel/runtime-config= -resource.html#GUC-MULTIXACT-MEMBER-BUFFERS=C2=A0 =C2=A0

I have = no idea if SLRU directly affects serialized transactions, I would suspect t= hat it does as SLRU affects all transactions and if it overflows bad things= start happening.=C2=A0 The next time this happen look at the replica to se= e if there are any long running transactions

All t= he conditions I can think of that can cause this is a=C2=A0 transaction sit= ting out there holding onto an XID causing the serialized=C2=A0transactions= to wait=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0

Thank you
Justin
=C2= =A0 =C2=A0
--000000000000cea489063e635bb4--