Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y0tWK-0004MA-4W for pgsql-odbc@arkaria.postgresql.org; Tue, 16 Dec 2014 14:54:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y0tWJ-0002oP-2Y for pgsql-odbc@arkaria.postgresql.org; Tue, 16 Dec 2014 14:54:39 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y0tWG-0002iN-9i for pgsql-odbc@postgresql.org; Tue, 16 Dec 2014 14:54:36 +0000 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Y0tWC-0003pj-PX for pgsql-odbc@postgresql.org; Tue, 16 Dec 2014 14:54:34 +0000 Received: from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com [10.113.161.72]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 21B8B2832C; Tue, 16 Dec 2014 06:54:30 -0800 (PST) Received: from EX13-CAS-011.vmware.com (EX13-CAS-011.vmware.com [10.113.191.63]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 1BA62B1CCB; Tue, 16 Dec 2014 06:54:30 -0800 (PST) Received: from EX13-MBX-024.vmware.com (10.113.191.44) by EX13-MBX-004.vmware.com (10.113.191.24) with Microsoft SMTP Server (TLS) id 15.0.913.22; Tue, 16 Dec 2014 06:54:24 -0800 Received: from [192.168.1.90] (10.113.160.246) by EX13-MBX-024.vmware.com (10.113.191.44) with Microsoft SMTP Server (TLS) id 15.0.913.22; Tue, 16 Dec 2014 06:54:11 -0800 Message-ID: <5490477E.5000303@vmware.com> Date: Tue, 16 Dec 2014 16:53:50 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.3.0 MIME-Version: 1.0 To: Gaurav Srivastava CC: Subject: Re: High CPU shoot during poll retry References: <548B569D.4040008@vmware.com> In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.113.160.246] X-ClientProxiedBy: EX13-CAS-013.vmware.com (10.113.191.65) To EX13-MBX-024.vmware.com (10.113.191.44) X-Pg-Spam-Score: -6.9 (------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org On 12/13/2014 04:48 AM, Gaurav Srivastava wrote: > We are providing timeout value as 0 or -1 in poll() timeout field meaning > zero timeout or infinite wait . During zero timeout case poll will > immediately return with return value as zero and come out of loop.But from > the places where this api SOCK_wait_for_ready()is called , it is checked > that return value is 0 or more > > if (SOCK_wait_for_ready(sock, FALSE, FALSE) >= 0) > > goto retry; > In case of zero timeout if reading fd is not ready, it will go into > continuous retries and in case of access load suppose 200k > registrations,10k calls running it will result CPU to shoot very high. The above call passes nowait==FALSE. It will wait. The callers that pass nowait==TRUE look like this: > if (!maybeEOF) > { > int nready = SOCK_wait_for_ready(self, FALSE, TRUE); > if (nready > 0) > { > maybeEOF = TRUE; > goto retry; > } > else if (0 == nready) > maybeEOF = TRUE; > } > if (maybeEOF) > SOCK_set_error(self, SOCKET_CLOSED, "Socket has been closed."); > else > SOCK_set_error(self, SOCKET_READ_ERROR, "Error while reading from the socket."); > return 0; On the first iteration, it calls SOCK_wait_for_ready() with zero timeout, to check if the socket is immediately readable. If it is, it retries once. Otherwise it throws an error. > This is the actual problem statement,please let me know if i was able to > made my point clear. > > If yes,then other than putting usleep() before every retry can we provide > better solution? I solved my issue using usleep If you can create a test program to reproduce the problem you're seeing, I can have a look. Or you could attach a debugger and trace through where it's actually looping. - Heikki -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc