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 1vDZ4S-00BPPi-B4 for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Oct 2025 02:04:23 +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 1vDZ4R-00AKFV-96 for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Oct 2025 02:04:22 +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.94.2) (envelope-from ) id 1vDZ4R-00AKFM-0y for pgsql-bugs@lists.postgresql.org; Tue, 28 Oct 2025 02:04:22 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vDZ4O-00481u-0m for pgsql-bugs@lists.postgresql.org; Tue, 28 Oct 2025 02:04:21 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 59S24FMp2485782; Mon, 27 Oct 2025 22:04:15 -0400 From: Tom Lane To: Richard Guo cc: Lori Corbani , Thomas Munro , "pgsql-bugs@lists.postgresql.org" Subject: Re: [EXTERNAL]Re: BUG #19094: select statement on postgres 17 vs postgres 18 is returning different/duplicate results In-reply-to: References: <19094-6ed410eb5b256abd@postgresql.org> <1970841.1761402665@sss.pgh.pa.us> <2441795.1761593103@sss.pgh.pa.us> <2447089.1761595976@sss.pgh.pa.us> Comments: In-reply-to Richard Guo message dated "Tue, 28 Oct 2025 09:58:50 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2485780.1761617055.1@sss.pgh.pa.us> Date: Mon, 27 Oct 2025 22:04:15 -0400 Message-ID: <2485781.1761617055@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo writes: > AFAICT, there are 3 possible options for a fix. > 1) Revert aa86129e1. > 2) Modify the code to perform atomic operations on the matched flag > using a CAS (or a similar) mechanism when running in parallel > execution. > 3) Disable parallel right semi joins in the planner. Right. I agree that #3 is the most attractive stopgap answer. We can look into #2 later, but it doesn't sound like something to back-patch. (The main problem according to my brief look is that t_infomask2 is uint16, but we haven't built out any 16-bit atomic primitives; perhaps they do not exist everywhere.) > (I'm still trying to understand why concurrent access to the matched > flag in cases other than right semi joins (such as right or full > joins) doesn't lead to concurrency issues.) I believe PRSJ is the only case where we need to set and concurrently inspect the HEAP_TUPLE_HAS_MATCH flag in a shared hashtable. I have a nasty feeling that this was well understood back when we first did parallel hash join, which is why it wasn't done already. Apparently the problem didn't get documented though, or at least not in any place you chanced to look. Looking at the code now, ExecParallelScanHashTableForUnmatched also has unprotected tests (not sets) of the flag, but I think that may be okay because we shouldn't still be mutating the flags while that runs. regards, tom lane