Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y1ExA-0002MQ-P9 for pgsql-odbc@arkaria.postgresql.org; Wed, 17 Dec 2014 13:47:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y1Ex9-0002zZ-Gu for pgsql-odbc@arkaria.postgresql.org; Wed, 17 Dec 2014 13:47:47 +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 1Y1Ex8-0002zS-FH for pgsql-odbc@postgresql.org; Wed, 17 Dec 2014 13:47:46 +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 1Y1Ex5-00049H-CC for pgsql-odbc@postgresql.org; Wed, 17 Dec 2014 13:47:44 +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 2E0802883D; Wed, 17 Dec 2014 05:47:42 -0800 (PST) Received: from EX13-CAS-003.vmware.com (EX13-CAS-003.vmware.com [10.113.191.53]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 28D37B147E; Wed, 17 Dec 2014 05:47:42 -0800 (PST) Received: from EX13-MBX-024.vmware.com (10.113.191.44) by EX13-MBX-005.vmware.com (10.113.191.25) with Microsoft SMTP Server (TLS) id 15.0.913.22; Wed, 17 Dec 2014 05:48:49 -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; Wed, 17 Dec 2014 05:46:59 -0800 Message-ID: <54918945.3070309@vmware.com> Date: Wed, 17 Dec 2014 15:46:45 +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> <5490477E.5000303@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/17/2014 07:21 AM, Gaurav Srivastava wrote: > Hi Heikki, > > Just to explain a bit more about the case "nowait==FALSE" > > We used this fix "Rip out broken retry/timeout logic in > SOCK_wait_for_ready" as in few scenarios our clients also get stuck in > infinite wait and our design is such that none of our process can wait > little longer than few secs if this happens preventive actions are taken > resulting re-initialization of the process. > > > In order to avoid that wait situation we did slight modification i.e. > making "nowait" TRUE everywhere in SOCK_wait_for_ready() API which resolved > our poll() wait issue after your fix,thanks for that but later to that this > high CPU issue has come. > > We resolved it using micro sleep,but still looking for a better solution,as > we don't have much understanding of ODBC. Ok. Well, all I can say to that is "don't do that". There isn't anything wrong with SOCK_wait_for_ready, as it's used in unmodified psqlodbc. One idea is to have a separate watchdog thread or alarm signal handler, and if an operation takes longer than you tolerate, have the watchdog thread forcibly close() the socket. That will wake up the thread blocked on the socket. You'll still need to hack psqlodbc to get the file descriptor of the socket so that you can close() it, but it seems less risky. - Heikki -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc