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 1wgqbq-006RzO-1w for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Jul 2026 21:12:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wgqbo-0030wQ-1Q for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Jul 2026 21:12:08 +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 1wgqbo-0030wI-0U for pgsql-hackers@lists.postgresql.org; Mon, 06 Jul 2026 21:12:08 +0000 Received: from lahtoruutu.iki.fi ([185.185.170.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 1wgqbj-000000027mv-09yf for pgsql-hackers@postgresql.org; Mon, 06 Jul 2026 21:12:07 +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 4gvH9R5HLlz49Pxf; Tue, 07 Jul 2026 00:11:55 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1783372316; 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=rIG7gEtNN0A8U4+wwqudF7qKT3Nbk9f5FrJtoCWCdh4=; b=KWVz0c3cqTd828kJeRD0iCW8Bu/X1+CtJW9wNxy/zOJLsF+AHmAZNBDFQbHCJ/HWqy19pP uUL0ODaQYjbENi+7ARcQZlAWwFg187GITAxKH4Ad8X7bFE+Ad+zJYEzmkAG2sPsw9AZZP0 wIvdbYB6CKRv0Vj7rf4K79MEM2GWPMisHqIlsBTeG84hbkyZZhIAgNuNoQ6dPEsp8h72j7 RdrvVmSuoZ7DGh9jvfkAaEqn7aG53744HHtvTQ7DrlMqKSS4+FTnpr5n0eLuFvl1E18YYl IE4h/wo4S2jGRwhRuUs47OQoW8a/ZWiO1Kjm/yDCDZHzUFHuzSyYjKc1lNrtYQ== ARC-Seal: i=1; a=rsa-sha256; d=iki.fi; s=lahtoruutu; cv=none; t=1783372316; b=OTQgnoBJl0piCUhRMKGh9mqD0Yz5d6pHWmcTh0yLoYRPwA3kzMjR0RQNUNI0F4kZaTN9Si AvobPkjcR/4/BJEA1H6p816eOl87GDmr5rP0YNMlvQwncal0EWLsz0a7osAIZxLpXk+yjp 6kD7xCdjqB/rQ4u551pfv0dGfNfgWcA8WqIx+Gd8z4o5vXZQ3xrJ086NDUSGAj1JtYeoXa HOp+sf4vRXQAHaxdD3IqYEJeVnlrmF7TbAuwKCMvdjpo7RfGFjbipln0whsojBxk/J5otl Ds8JBmpVUKez4IXWKDDoQDmP2oATRksLaENQwqo3UjAUnTp+NA9oeXjcLKcuWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1783372316; 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=rIG7gEtNN0A8U4+wwqudF7qKT3Nbk9f5FrJtoCWCdh4=; b=GW7jT0EDTlRvAk+4WTD2A9nyaSXxdzI5qpnaRhBDj2hfTecD+X8L4wS0qWub1UlkPDCDay gRYL/uOMrNVqbyi6mL2t9cROnhSKAVamR7g3fsBJTnzs84idBF+OgykLaBWtpvI8lHVYzy KTVAc4J0ifIxmzYY5etrvmj5P+PzXRbJMI8HFhH3rqSpkeqJsvVVIzSfQIRHaAJmJOYREb s+TU6R+16uqYyEZce8OhuDPjUoV4rd+wvT6bqHSGApP3fSqPBpx7nIeSBoCa3soUb0Tg23 jlVtGkz72RfYyaHNilqGKMMhkN8hgXRlHgfp+Q/4ysUkA9WgcMFr9NOG1z3DQg== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi Message-ID: <5e4a28ec-d5e1-4817-889c-b8aefe5f48ed@iki.fi> Date: Tue, 7 Jul 2026 00:11:54 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Can we get rid of TerminateThread() in pg_dump? To: Thomas Munro , Jelte Fennema-Nio Cc: Bryan Green , pgsql-hackers , Tom Lane , Kyotaro Horiguchi References: <56821e0d-bfd5-4619-b13f-12e28c78289b@iki.fi> Content-Language: en-US From: Heikki Linnakangas In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 05/07/2026 08:03, Thomas Munro wrote: > On Sat, Jul 4, 2026 at 11:15 PM Jelte Fennema-Nio wrote: >> On Sat, 4 Jul 2026 at 02:51, Thomas Munro wrote: >>> We don't actually care about the threads >>> themselves, and it doesn't seem that great if we have to introduce an >>> IPC ping-pong of some kind with each thread. >> >> Agreed. But I do agree with Heikki that swapping out stderr seems pretty >> hacky. At the very least because now the main thread cannot write to >> stderr either anymore (which is why you removed the "terminated by user" >> write I guess). >> >> How about instead we do something like the attached? > > That's definitely nicer, if we know that all potential error logging > caused by cancellation happens in a context that can check the flag. +1, much nicer! > I didn't even look into that, because I was deliberately trying to > avoid needing atomics from here, because I need this to work on Unix > too, and I didn't want to open too many cans of worms at the same > time. Hence the appeal of a simple async-signal-safe system call that > has the right concurrency properties already and works also on Windows > without a separate code path. But... reaching for the can opener... > > 1. If we're ready to drop VS < 2022 and GCC < 4.9, we could just use > directly in frontend code (independently of the project > to use it in the backend). > 2. If we're not ready yet we could make "port/atomics.h" or selected > parts of it frontend-allowed. > 3. Maybe all we really need for this case is memory barriers, and we > could move those out to a frontend-allowed header. To be honest, I didn't realize we didn't allow "port/atomics.h" in frontend code. I think spinlock-simulated 64-bit atomics is the only thing that wouldn't just work. - Heikki