From: Heikki Linnakangas <hlinnakangas@vmware.com>
To: Gaurav Srivastava <gaurav.srivastava@globallogic.com>
Cc: pgsql-odbc@postgresql.org
Subject: Re: High CPU shoot during poll retry
Date: Tue, 16 Dec 2014 16:53:50 +0200
Message-ID: <5490477E.5000303@vmware.com> (raw)
In-Reply-To: <CAAXqS3BFjOe8MBwprVqLwTH4BFvU55v6fGjd77XTZdj19raDuQ@mail.gmail.com>
References: <CAAXqS3Aag2vVu9yKQvb-jdSPuTkNSi_X6HphQcz4adgXL1gOFQ@mail.gmail.com>
<548B569D.4040008@vmware.com>
<CAAXqS3BFjOe8MBwprVqLwTH4BFvU55v6fGjd77XTZdj19raDuQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-odbc>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: hlinnakangas@vmware.com, gaurav.srivastava@globallogic.com
Subject: Re: High CPU shoot during poll retry
In-Reply-To: <5490477E.5000303@vmware.com>
References: <CAAXqS3Aag2vVu9yKQvb-jdSPuTkNSi_X6HphQcz4adgXL1gOFQ@mail.gmail.com> <548B569D.4040008@vmware.com> <CAAXqS3BFjOe8MBwprVqLwTH4BFvU55v6fGjd77XTZdj19raDuQ@mail.gmail.com> <5490477E.5000303@vmware.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox