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 1wUUIj-001C3Y-0j for pgsql-bugs@arkaria.postgresql.org; Tue, 02 Jun 2026 18:57:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wUUIi-00Fgix-06 for pgsql-bugs@arkaria.postgresql.org; Tue, 02 Jun 2026 18:57:20 +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 1wUTzA-00FVdQ-2A for pgsql-bugs@lists.postgresql.org; Tue, 02 Jun 2026 18:37:08 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wUTz8-00000000uE4-0KKd for pgsql-bugs@lists.postgresql.org; Tue, 02 Jun 2026 18:37:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=j7ni5sEeZH6c6wAHjHvc4nypF7uTOdrP6LJeo0msunU=; b=z7lpzUf68ki7Ip/VYfTlKCONS+ w981EcQxh8GcIq2SzWM6gDcboNbtanbPCTb4nvaxu4aDc6r9xl9znpq44Y3sOMbRaR3z1LM5hNc3U gC8Ommb+LmPu7k8cxUp05M+U2SWlbYmdYRvreKMF0GQd9oILXWEIOqQQiHpu5MGPDuGpoaTWvYQJk 3TUKfjMNx9APAu2+ElS0sLAaTOPHqUXppUWiyf9F3C7ixcAPKe6tBZtyw6riMnckpHGHwaxP44xi+ gPWhEGbupfG8zM489e38K8HG9shVx3nt1gQO5YwQ1Wp6VZDwh0bDtrlK9okaOb0JBt5F44UyzxrL6 HMrN76Ww==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wUTz6-002QF8-0o for pgsql-bugs@lists.postgresql.org; Tue, 02 Jun 2026 18:37:04 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wUTz5-005L99-0h for pgsql-bugs@lists.postgresql.org; Tue, 02 Jun 2026 18:37:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19505: Some weird spikes postgresql processes in database (up to 200k sometime) without apparent reasons. To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: maxim.boguk@gmail.com Reply-To: maxim.boguk@gmail.com, pgsql-bugs@lists.postgresql.org Date: Tue, 02 Jun 2026 18:36:47 +0000 Message-ID: <19505-7ec445dffe2732d2@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19505 Logged by: Maxim Boguk Email address: maxim.boguk@gmail.com PostgreSQL version: 18.4 Operating system: Ubuntu 24.04.4 LTS Description: =20 I started investigation of this issue after found that process count of postgresql on my replica sometime jump to 200k+ (with max_connections=3D1000 and real connections under 100 most time). Somehow single (seems random by always heavy/analytical) query spawn thousands of the threads and tens thousands of parallel workers. After some logging I caught one snapshot (ps -u postgres -L -o pid,tid,ppid,lstart,args -ww 2 ) with 39257 processes: [postgres@db ~/tmp]$ zcat ps-L-2026-06-02_17-40-22.gz | wc -l 39257 Main content is: PID TID PPID StartTime command 2158552 2158552 948705 Tue Jun 2 17:40:17 2026 postgres: 18/main: background_shared db [local] SELECT Then: The same PID but 1620 different TIDS. PID TID PPID StartTime command #main process 2158557 2158557 948705 Tue Jun 2 17:40:18 2026 postgres: 18/main: background_shared db [local] SELECT #1620 threads 2158557 2158607 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: background_shared db [local] SELECT 2158557 2158608 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: background_shared db [local] SELECT 2158557 2158609 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: background_shared db [local] SELECT Then, 37571 rows!!! of: PID TID PPID StartTime command 2158579 2159176 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: parallel worker for PID 2158557 2158579 2159179 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: parallel worker for PID 2158557 2158579 2159183 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: parallel worker for PID 2158557 2158579 2159196 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: parallel worker for PID 2158557 2158579 2159198 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: parallel worker for PID 2158557 2158579 2159202 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: parallel worker for PID 2158557 I double checked the query (it had been logged in database log): it run with 6 worker processes and without any issues on manual run. Related db configuration: max_connections =3D 1000 max_worker_processes =3D 128 # (change requires restart) max_parallel_workers_per_gather =3D 16 # limited by max_parallel_workers max_parallel_workers =3D 64 io_method =3D io_uring # worker, io_uring, sync io_max_concurrency =3D -1 # Max number of IOs that one process jit =3D on (usual suspect in case of weird things going on) Given that situation happens like 1-10 times per hour (and lead for short LA spikes up to 10000) - it's seriously affect the database replica performance. No external/non-standard/C extensions except of pgq and postgis loaded into the database. I can look for any additional information and perform any local research but currently I'm out of ideas what my next steps should be. PS: it's seems that the issue could be triggered by different queries, but not the one particular.