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 1wbleM-002pGI-2z for pgsql-bugs@arkaria.postgresql.org; Mon, 22 Jun 2026 20:53:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wbleL-0087DA-2Q for pgsql-bugs@arkaria.postgresql.org; Mon, 22 Jun 2026 20:53:45 +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 1wbleK-0087D2-2d for pgsql-bugs@lists.postgresql.org; Mon, 22 Jun 2026 20:53:45 +0000 Received: from fhigh-a4-smtp.messagingengine.com ([103.168.172.155]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wbleG-00000001dsE-071z for pgsql-bugs@lists.postgresql.org; Mon, 22 Jun 2026 20:53:43 +0000 Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfhigh.phl.internal (Postfix) with ESMTP id 3919914000FC; Mon, 22 Jun 2026 16:53:38 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Mon, 22 Jun 2026 16:53:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1782161618; x=1782248018; bh=hRC1bChekW BmD8wGCzHUQaAll/ToGnWoAbYZaQf7+RU=; b=Kw/m3SzgJrp8ZiMWFL8JTyOwif CHzXLen5EBfVBJuGnVo1oOk5wUc5ARF+ran5O5iIOzpjC/2rDwW4ObsG5xtGJsW1 n7IH9UBRhLx/r7ma+j5e5LRluCsSF2rIijEklGxHHEBc9iijh5nlu0DbiVW4y09l zDwV440KxGCzFL3HvmKklldO6bkm7z/9pfWEAFeWAkJhbMP8G308DdkuLmNdxKgb bNxAXeXYG3q88/wP8Qzi4M2/MBidZ/ctGnQFlHd+xtIKb4M6vkFX00PUzg1Hra0c kEjMmiduNjo+gVNl0eGaEnYVAzMeo5Vf1yIxzkEGHoLsIYv4FpWYFkObFw2g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1782161618; x=1782248018; bh=hRC1bChekWBmD8wGCzHUQaAll/ToGnWoAbY ZaQf7+RU=; b=WVLMWnVdFrBKFZ51IsRHKGSx2duJVkvJIiL2mknyCys0r7ksVos MZclj8x3tlRRoQ/O3A4r/HhiRppQfUnXfoRecTiKUbrHV/QEjFeej6O6H0yi/dz1 WcA0DDaAB9gU1hnlfgoiuiIngtLl+ke4CGUSiCEndIz+9oIEbcN/tELrG3gj55Hn tmrT21ROj/+J/rD5S2vmacMrnS2zieaEbCYMT/E9DW80X5ZiPQrm+T0zh9ObEJ3n TSAedQmWHi0zoWyH9/quL0wQ4vKdnKjgCJs5lYgeK/5QJOZbhbA9Gw6vaNeyScmg mYT5JLHmuiTS3zO7KgfHLPf3ISocloM9IRQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGiaAjoJ8pewH4KqY+Nnl/B5bqOqztdHJQ+AGFX47DEJPuuE64MiV8p3Uoohj7ooe yCAdALn07Z7SYysEPotsVFPXqAyRoSTwufbaU9V+epoAOucy47lJ6TcrEjMDM2mYcidEKb 1Di3WvyyzkWesiatUlrNcTChlkSnizi6DGjH3Qkm9CBScWjYEqZpLF/c6a0G29vd9c1w7h x/FNO1h3GClut8JS73E/rkBXuRyMFfhyPNpfovfpwIZjGz8nLnrBntLYi//6TJGzCcw4TN P8+mGEksQAe7ZoB0kqha2VWaYovW+W2scF5M+G3d1Fq4AKxxP96/LIrDCO1NSvm7J//4bq L/i++K4Ki9OJWgwcxa8aPFyIbaBQpW8J9rLhxwXZymW9X7q6iJm6E/uvbW5/PbrY4jrycx KsrndZ3fTVPOThZtTfn1VBm/33Y8e5LAhOuCkS0mUTgVYjEzAhfk7IbTusqqDKg8rWtSSf WaxkduzpCIJdPQar9bhuwcN4ivLSywWol9Xz1rQlWCBi+ZGtFDX2bk+fN7gvjDPFtNkd32 VHQWw4Fj6nF26W2weke/AskhQrjooinW3yFnE1UjDSxSj35eUfX2bglZW/9yr9T7/nUXLO MGFXBUSjVJVEjGI4CKeBHvBKufRAayOnMbDe+p4oig1Ais0th6HeQAwtnS9A X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 22 Jun 2026 16:53:37 -0400 (EDT) Date: Mon, 22 Jun 2026 16:53:37 -0400 From: Andres Freund To: Maxim Boguk Cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19505: Some weird spikes postgresql processes in database (up to 200k sometime) without apparent reasons. Message-ID: References: <19505-7ec445dffe2732d2@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2026-06-22 23:22:53 +0300, Maxim Boguk wrote: > >> I started investigation of this issue after found that process count of > >> postgresql on my replica sometime jump to 200k+ (with max_connections=1000 > >> and real connections under 100 most time). You say upthread: > 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. I don't immediately see how the kernel worker thread creations leads to such an LA and/or replica performance issues. > Update: issue had been triggered by unconstrained spawn of helper threads > for io_method=io_uring > (thousands/ten thousands of helper "iou-wrk-****" threads per bitmap scan). Note that these are kernel controlled, not postgres controlled. Newer kernels will typically start fewer worker threads, because more of the IO can be handled "full asynchronously" (i.e. without workers). What is effective_io_concurrency set to? I assume io_max_concurrency = -1 ends up with io_max_concurrency = 64 (the max auto-tuned value)? > Switching to the io_method=worker fixed problem. Did that actually fix any performance issues? > Seems io_uring have some unexpected issues with unconstrained threads spawn. I don't really see how the query you described could trigger that many kernel worker threads. Within each backend that should be bound by io_max_concurrency (or perhaps io_max_concurrency * 2, due to the some kernel partitioning). That's a far cry from 1620. Across a parallel query it should be bound by by io_max_concurrency * #postgres processes involved in query. Assuming an effective_io_concurrency > 64, and io_max_concurrency = 64, your query shouldn't trigger more than 7 * 64 worker threads (due to the number of workers chosen) - clearly not a small number, but not 1620 (even if it were not within one process). And even if all 16 workers were used, that's 17*64, still a lot less. If this is happening with a current kernel, I think you need to make a bugreport to ubuntu. Greetings, Andres Freund