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 1v5nmG-00C9Ue-Mp for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Oct 2025 16:09:33 +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 1v5nmE-009BPh-HJ for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Oct 2025 16:09:31 +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 1v5nmE-009BPL-6i for pgsql-bugs@lists.postgresql.org; Mon, 06 Oct 2025 16:09:31 +0000 Received: from ewsoutbound.kpnmail.nl ([195.121.94.170]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v5nmC-000hwR-1F for pgsql-bugs@lists.postgresql.org; Mon, 06 Oct 2025 16:09:30 +0000 X-KPN-MessageId: e59db6e2-a2ce-11f0-9c77-005056ab378f Received: from smtp.kpnmail.nl (unknown [10.31.155.38]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id e59db6e2-a2ce-11f0-9c77-005056ab378f; Mon, 06 Oct 2025 18:09:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=demon.nl; s=demon01; h=content-type:from:to:subject:mime-version:date:message-id; bh=PmZ5Lea8uNhtuWRkaNRmWqhCOlSlu1aTGMG1QnetTvs=; b=Nx4KOPfW22ID1GePhPuPmh23pvoWx0c2hf+6cCJO0lsF1T9NOOowIVnJLzUveWwc0aDKEhi/S7yzn zU2dLmre5o2ok65L9+c9vqGzVgvQlSUgdmVja+pSkwSVOW3UFqFzItLCZN+n8u7Gft1RFIURuTODQm bl7J+GJUQfI2PDdtpL7CIVPdVY5X9+d6yn8tnKw8wH34msJvrvS5jJPrUr3EjYICMqsf7NEyaJUuOm fm4VI+pI139XBSkBfD3XmABOXGABrorakSUVnLmFtgt5dAfu/NCEawd4DpJ8EOIDvLml9Rvq1IHaRx twgepyF0zwFo//lhjtgucOdAMfZq6OQ== X-KPN-MID: 33|i3qxmSumA2UsaC4DsVMY1owe8hP3uKXcPNXlMX1iLv9exXHJPWOXIkNlFGFdOBX 8lMidZCe+ctDm+K6EVCFCRODGMhpseldBjI5v3E1gMp4= X-KPN-VerifiedSender: Yes X-CMASSUN: 33|3j30JLReZbRFJxFHMPKiz0Ofoz4XEgpBK11ipp2J4QYzBtLgbnhLmtyi1gxiiVK IaYzhIUvrqZAMyjOyZXQDuA== X-Originating-IP: 77.174.174.39 Received: from [192.168.1.35] (77-174-174-39.fixed.kpn.net [77.174.174.39]) by smtp.xs4all.nl (Halon) with ESMTPSA id d4b1ff7e-a2ce-11f0-a6c9-005056abf0db; Mon, 06 Oct 2025 18:09:26 +0200 (CEST) Message-ID: Date: Mon, 6 Oct 2025 18:09:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Potential "AIO / io workers" inter-worker locking issue in PG18? To: Andres Freund Cc: pgsql-bugs@lists.postgresql.org References: <32179d3f-3c28-4d71-88c6-f6678feaea4a@boeringa.demon.nl> Content-Language: en-US From: Marco Boeringa In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: Norton (VPS 251005-4, 5-10-2025), Outbound message X-Antivirus-Status: Clean List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Andres, I should have phrased it better. The high processor and core activity is not unexpected. The code is designed to saturate the processor and maximize throughput by careful design of the Python threading stuff. It is just that all the jobs send to PostgreSQL via ODBC for the specific step in the processing and with the small Italy extract, should return in less than 10 seconds (which they do in those lucky runs I do not observe the issue), but some of the jobs for the specific step don't, e.g. 30 jobs return within 10 seconds, then the remaining 14 unexpectedly get stuck for 2 hours before returning, all the while staying at the same high core usage they were initiated with. So some of the PostgreSQL database sessions, as I already explained show up in pgAdmin as 'active' with no wait events or blocking pids, simply take an excessive amount of time, but will ultimately return. The CPU time, as witnessed with 'top' in Ubuntu, is really spend in PostgreSQL and the database sessions, not Python, which is run in Windows, and doesn't show high CPU usage in the Windows Task Manager. This doesn't always happen, it is kind of random. One run with the Italy data will be OK, the next not. Marco Op 6-10-2025 om 16:34 schreef Andres Freund: > Hi, > > On 2025-10-05 10:55:01 +0200, Marco Boeringa wrote: >> This has worked really well in previous versions of PostgreSQL (tested up to >> PG17). However, in PG18, during the multi-threaded processing, I see some of >> my submitted jobs that in this case were run against a small OpenStreetMap >> Italy extract of Geofabrik, all of a sudden take > 1 hour to finish (up to 6 >> hours for this small extract), even though similar jobs from the same >> processing step, finish in less than 10 seconds (and the other jobs should >> as well). This seems to happen kind of "random". Many multi-threading tasks >> before and after the affected processing steps, do finish normally. >> >> When this happens, I observe the following things: >> >> - High processor activity, even though the jobs that should finish in >> seconds, take hours, all the while showing the high core usage. >> >> - PgAdmin shows all sessions created by the Python threads as 'active', with >> *no* wait events attached. > I think we need CPU profiles of these tasks. If something is continually > taking a lot more CPU than expected, that seems like an issue worth > investigating. > > Greetings, > > Andres Freund