Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bofHc-0000xm-Tb for pgsql-committers@arkaria.postgresql.org; Mon, 26 Sep 2016 23:26:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bofHc-0000le-9w for pgsql-committers@arkaria.postgresql.org; Mon, 26 Sep 2016 23:26:00 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bofHb-0000lX-KI for pgsql-committers@postgresql.org; Mon, 26 Sep 2016 23:25:59 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bofHY-0003ON-K2 for pgsql-committers@postgresql.org; Mon, 26 Sep 2016 23:25:58 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u8QNPbWJ023002; Mon, 26 Sep 2016 19:25:37 -0400 From: Tom Lane To: Fabien COELHO cc: Heikki Linnakangas , pgsql-committers@postgresql.org Subject: Re: pgsql: Refactor script execution state machine in pgbench. In-reply-to: References: <3089.1474920612@sss.pgh.pa.us> Comments: In-reply-to Fabien COELHO message dated "Mon, 26 Sep 2016 22:51:43 +0200" Date: Mon, 26 Sep 2016 19:25:37 -0400 Message-ID: <23001.1474932337@sss.pgh.pa.us> X-Pg-Spam-Score: -4.9 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org Fabien COELHO writes: > Could you catch the process to identify the infinite loop? I think the problem is here (pgbench.c lines 4550ff): bool ready; ... ready = FD_ISSET(sock, &input_mask); The result of FD_ISSET isn't a bool, it's an int. I can see in the looping process that the backend connection has socket FD 8, and I think what is happening is that FD_ISSET is returning 1<<8 and that's getting truncated to zero to fit in a bool (char), so that the code just below doesn't call doCustom and we never consume the waiting result. I couldn't reproduce this in a manual build, but perhaps the socket number assignments are a bit different in the buildfarm environment. Rather than s/bool/int/, I'm inclined to remove the "ready" variable altogether. We have exactly zero other places that make any assumptions about the width of FD_ISSET results, and I don't see a good reason why this needs to be the first one. I see a number of other things that look pretty infelicitous in this code --- for example, why is the loop at lines 4440ff break'ing after it comes across the first socket to wait for? That sure looks like it will fail to deal with more than one wait-able socket, rather destroying the point of having multiple threads. Will fix. regards, tom lane -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers