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 1wgWB0-006EXH-2x for pgsql-hackers@arkaria.postgresql.org; Sun, 05 Jul 2026 23:23:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wgW9z-00E5a8-0U for pgsql-hackers@arkaria.postgresql.org; Sun, 05 Jul 2026 23:22:03 +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 1wgW9y-00E5a0-2p for pgsql-hackers@lists.postgresql.org; Sun, 05 Jul 2026 23:22:02 +0000 Received: from lahtoruutu.iki.fi ([2a0b:5c81:1c1::37]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wgW9w-00000001wzy-2N6X for pgsql-hackers@lists.postgresql.org; Sun, 05 Jul 2026 23:22:02 +0000 Received: from [10.0.2.15] (unknown [130.41.208.2]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4gtk5y27QDz49Pyc; Mon, 06 Jul 2026 02:21:58 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1783293718; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R9czP3WBXL3iSLdwsAP5aNB+1oFRcmfvlqHKxympgiU=; b=QhQFgaReflDno2z7BkNMbPahjDWu6NvXK6D8rO4hnbgBAE9cIOkuATLY0T5n0U56xUPG9n LwQzxNd0yEazCjPbsqnjKC4ajMfmMJQ7RnJCSMe1IZxK4aEhnU0EuLW04CwWkdVcDvMI89 +NnlPAiABNY1IrwcwTACGjKM32UpnksF28AT+ciqRk52GyrsP2PPhsARn4pdKn+Bk0d8gI JOjeNbs6+Uzg68qR9Po9Cn7lcJAVYXZyZVhHZeMUyVdtRnJNJGCU0lW/VwKXw3ykHdqsdM NWP7cnpJwswneJMkI9lKSKZAf7wfHydK8Q75NyPC+zhPllDZGqn30BiM83t+gA== ARC-Seal: i=1; a=rsa-sha256; d=iki.fi; s=lahtoruutu; cv=none; t=1783293718; b=Lh08ExftH6EYSYZdRLqqtBokr+N0RxfFiY0zGMXS09hoxkFi1DtebUQSOZyejuCfZiudMo 9NXKMQwQoyFPVYbpuSkH6WYAeo/ZS5sm29QECtXdQvpH+5iE5IaEwzRKnjvAbHyEbXGRas cVKLi3T0qUvnPkLmXnb+1lpLzZFZgvtc5vRabjpZm5HXru96zngAozp2c6emTdGLhg9gZA j+wu2CoAaDYBRx0wxCqvbhCacik5lHqpt3D55yo5DCoGMD4h6oVb9ISyGP8t+yZBcGISK8 MOTFG/qZB2iH4BhHm9qn0lrJj01PL4PQAOB5Ywsc07z+DN4p0fuuy3Mba/JpTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1783293718; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R9czP3WBXL3iSLdwsAP5aNB+1oFRcmfvlqHKxympgiU=; b=GUFs6bP+FB1vOgKQGghu2Jqx5EUc5bFWJ//cTeORTEcNYS9a4MI5ZZg8HsONKV/4vFLedM 5JpmcuFSchKCc//kYrkiDhYRn7fKEziUDqdaDavAd/Pd7o7UeXOhsmBenjHs1PJulN71xf PYUejjOXmA40r26nFCMr3mxEzMOqPVp7UqVCkXUOoGbbF/4EcUGtAWWvgBK+ZtohPbFsN1 Q2SS+yeGQCb24MMLPophqqOgfx4fyAbaFkedAqz+MOAvgkTMPdz4bBLBj3TK/50ER9zlqE CnkXisGnn2M3oaX+Ajpc6Dh0914lTvHKAR42TG7Eix85KWrKqONekahL+To5fA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi Message-ID: <3cccb1c0-4852-478c-9c5d-fbffea56ad53@iki.fi> Date: Mon, 6 Jul 2026 02:21:56 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pg_dump: use threads for parallel workers on all platforms To: Bryan Green , PostgreSQL Hackers Cc: Thomas Munro , Andrew Dunstan References: <8c712d76-ecf7-4749-a6d8-dddc01f298ec@gmail.com> Content-Language: en-US From: Heikki Linnakangas In-Reply-To: <8c712d76-ecf7-4749-a6d8-dddc01f298ec@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 02/07/2026 19:30, Bryan Green wrote: > None of this is broken; it works. It's threads pretending to be > processes because the code was written for processes, and the port kept > the protocol rather than rethinking it. I'd like to stop. > > One model everywhere should be threads on all platforms, coordinated by > an in-process work queue-- a mutex and a couple of condition variables-- > instead of two worker models bridged by an inter-process protocol. +1 > To be clear, the unification is on the queue, not on what Windows does > today. Teaching the non-Windows side to talk to its own threads over a > socket, a byte at a time, would just be the same trick on more > platforms-- that's the part worth deleting, not copying. > > I've done the Windows half, both to prove it out and because it's the > coordination layer the non-Windows side would adopt. ... I see why you developed this that way, and it makes a lot of sense. However, it has one downside: the Windows-only code cannot be tested without Windows. At quick glance, it looks reasonable, but I'm a little nervous committing more Windows-only code without being able to easily play with it myself. Once you have the final patch ready to switch non-Windows systems to threaded model too, that gets easier. > With the thread rework, fmtId's static return value, is now > _Thread_local. +1. This is the first _Thread_local in our codebase. It's in C11, so it should just work, but we'll see if the buildfarm shows any surprises... With this, the getLocalPQExpBuffer hook is never set. I think we can just remove it, and rename defaultGetLocalPQExpBuffer() to getLocalPQExpBuffer() directly. I noticed that we currently call setFmtEncoding() in multiple places in src/bin/pg_dump. I haven't looked at them closely, but I wonder if there's some kind of thread-safety hazards there even without these patches. And what about the 'quote_all_identifiers' global variable? Is that set correctly in both models? I guess it's inherited through fork(). - Heikki