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 1sc0Hz-0037rX-E7 for pgsql-general@arkaria.postgresql.org; Thu, 08 Aug 2024 10:22:35 +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 1sc0Hx-00DKOO-TQ for pgsql-general@arkaria.postgresql.org; Thu, 08 Aug 2024 10:22:33 +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 1sc0Hx-00DKOG-H2 for pgsql-general@lists.postgresql.org; Thu, 08 Aug 2024 10:22:33 +0000 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sc0Hu-003map-SI for pgsql-general@lists.postgresql.org; Thu, 08 Aug 2024 10:22:32 +0000 Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3db145c8010so523920b6e.3 for ; Thu, 08 Aug 2024 03:22:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723112548; x=1723717348; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=3rdMnOSmC3VnaR4a6zP9foxGmbdaquNRFDSrSyUcaFc=; b=TLKL1pamOzNhV5YjE4bSWfz14ncelev4ijwbgop1k55612rBaTrzufDHvm+W0wjsBH qp0pyH9RVSTS0Fkd9abD1wTDnglZxeYEeX6HyTGjyduk28TOQ4dIelx//gO31nREXl8r EBuhVufuNnndznPt6s+y6m4Iai6DJeIx4ZoFtpivHoFwn/7juWuLh34aLuhqsryn+rj8 gRok7llPDHeCBGKeYVqH9E5dR8J7WvY+HSVndzU57Z265Zx3mU/qrUq8zjStvHiwDLRy iJytVdzwkAAnw54Rgnn2afYXdYbAs6igEWz3/z/8qawTf1ohRW75z5ZRzJhMgs1QSY0Y HVKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112548; x=1723717348; h=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=3rdMnOSmC3VnaR4a6zP9foxGmbdaquNRFDSrSyUcaFc=; b=J8dIvqms9vinxrxQSBjZiQ0wkyw1MOCfaxgX4xZfCeSs51hFCVL3SF2EEYktwFCx10 CA9yJU1q368L4U1Q/h9WIJ5P3CFpuiG0B5B2CBHREpeudWTBd+zoDQkvzb/Et4Oiovz0 EVt6hxWBXgGApgi9evoZlSCy+xEQ6a06XVqlQNN5xmFu40soamV36rdTFLD0co58Zxek 9jYJ2b+m9jyTadyXjR7QoSJKB9GTxfjzFBbc8/Svn6XAzglOKyiK8MLQr04i3oAbTe6l XnSagvIb+soLGGTNWrNOKIXLtwacFo4S1/3egQ+ufNqdXcJm/UWP7ljpKLr+/u5PVXox 4FAA== X-Gm-Message-State: AOJu0YxMX2tZXARWH3mLhtW6ZWv+0bSJIG1YCegUv9KJlFAiGTU7xHRs /gxcKYglurH5j6uyPjABp3rux3xv71B2hCSqYpdzaT3RUr1Wac1bUWPxanJg+sszEhiUmgY3P+b xvhUPgp6pcn4T0YVdZOKujW81Edt7PqgQ X-Google-Smtp-Source: AGHT+IEf1GP1Pw+rbbj2LcTTEApEP59A3trf6RjN5ks+rWJOdJi+IzYzpCiU8lZlBGRm/PJY6Bdgv+D8cFf8wh6LxwQ= X-Received: by 2002:a05:6808:210f:b0:3d9:2b15:65d4 with SMTP id 5614622812f47-3dc3b4266b6mr1734705b6e.21.1723112548463; Thu, 08 Aug 2024 03:22:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ron Johnson Date: Thu, 8 Aug 2024 06:22:17 -0400 Message-ID: Subject: Re: Vacuum full connection exhaustion To: "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="0000000000005bfa73061f296782" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000005bfa73061f296782 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Aug 8, 2024 at 5:18=E2=80=AFAM Costa Alexoglou w= rote: > Hey folks, > > I noticed something weird, and not sure if this is the expected behaviour > or not in PostgreSQL. > > So I am running Benchbase (a benchmark framework) with 50 terminals (50 > concurrent connections). > There are 2-3 additional connections, one for a postgres-exporter > container for example. > > So far so good, and with a `max_connections` at 100 there is no problem. > What happens is that if I execute manually `VACUUM FULL` > Off-topic, but... *WHY?? *It almost certainly does not do what you think it does. Especially if it's just "VACUUM FULL;" the connections are exhausted. > Connect to the relevant database and run this query. Don't disconnect, and keep running it over and over again as you run the "VACUUM FULL;". That'll tell you exactly what happens. select pid ,datname as db ,application_name as app_name ,case when client_hostname is not null then client_hostname else client_addr::text end AS client_name ,usename ,to_char((EXTRACT(epoch FROM now() - backend_start))/60.0, '99,999.00') as backend_min ,to_char(query_start, 'YYYY-MM-DD HH24:MI:SS.MS') as "Query Start" ,to_char((EXTRACT(epoch FROM now() - query_start))/60.0, '99,999.00') as qry_min ,to_char(xact_start, 'YYYY-MM-DD HH24:MI:SS.MS') as "Txn Start" ,to_char((EXTRACT(epoch FROM now() - xact_start)/60.0), '999.00') as txn_min ,state query from pg_stat_activity WHERE pid !=3D pg_backend_pid() order by 6 desc; > > Also tried this with 150 `max_connections` to see if it just =E2=80=9Cdou= bles=E2=80=9D the > current connections, but as it turned out, it still exhausted all the > connections until it reached `max_connections`. > Double it again? > > This was cross-checked, as the postgres-exporter could not connect, and I > manually was not allowed to connect with `psql`. > > Is this expected or is this a bug? > Depends on what you set these to: autovacuum_max_workers max_parallel_maintenance_workers max_parallel_workers max_parallel_workers_per_gather max_worker_processes --=20 Death to America, and butter sauce! Iraq lobster... --0000000000005bfa73061f296782 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Aug 8, 2024 at 5:18=E2=80=AFAM Co= sta Alexoglou <costa@dbtune.com&= gt; wrote:
Hey folks,

I noticed somethin= g weird, and not sure if this is the expected behaviour or not in PostgreSQ= L.

So I am running Benchbase (a benchmark framework) with 50 termina= ls (50 concurrent connections).
There are 2-3 additional connections, o= ne for a postgres-exporter container for example.

So far so good, an= d with a `max_connections` at 100 there is no problem. What happens is that= if I execute manually `VACUUM FULL`

Off-topic, but... WHY??=C2=A0=C2=A0It almost certainly does n= ot do what you think it does. Especially if it's just "VACUUM FULL= ;"

the connections are exhausted.

Connect to the relevant database and run this = query.=C2=A0 Don't disconnect, and keep running it over and=C2=A0over a= gain as you run the "VACUUM FULL;".=C2=A0 That'll tell you ex= actly what happens.
select pid
=C2=A0 =C2=A0,datname as db
=C2=A0 =C2= =A0,application_name as app_name
=C2=A0 =C2=A0,case
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 when client_hostname is not null then client_hostname
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 else client_addr::text
=C2=A0 =C2=A0 end AS cl= ient_name
=C2=A0 =C2=A0,usename
=C2=A0 =C2=A0,to_char((EXTRACT(epoch= FROM now() - backend_start))/60.0, '99,999.00') as backend_min
= =C2=A0 =C2=A0,to_char(query_start, 'YYYY-MM-DD HH24:MI:SS.MS') as "Query Start"
=C2=A0 =C2=A0,to_cha= r((EXTRACT(epoch FROM now() - query_start))/60.0, '99,999.00') as q= ry_min
=C2=A0 =C2=A0,to_char(xact_start, 'YYYY-MM-DD HH24:MI:SS.MS') as "Txn Start"
=C2=A0 =C2=A0= ,to_char((EXTRACT(epoch FROM now() - xact_start)/60.0), '999.00') a= s txn_min
=C2=A0 =C2=A0,state
=C2=A0 =C2=A0query
from pg_stat_acti= vity
WHERE pid !=3D pg_backend_pid()
order by 6 desc;
=C2=A0

Also tried this with 150 `max_connections` to see i= f it just =E2=80=9Cdoubles=E2=80=9D the current connections, but as it turn= ed out, it still exhausted all the connections until it reached `max_connec= tions`.

Double it again?
=C2=A0

This was cross-checked, as the postgres-exporter could= not connect, and I manually was not allowed to connect with `psql`.
Is this expected or is this a bug?
=C2=A0=
Depends on what you set these to:
autovacuum_max_workers
max_parallel_maintenance_workers
max_para= llel_workers
max_parallel_workers_per_gather
max_worker_processes

--=
Dea= th to America, and butter sauce!
Iraq lobster...
--0000000000005bfa73061f296782--