[HACKERS] pgbench stuck with 100% cpu usage - Mailing list pgsql-hackers

From Pavan Deolasee
Subject [HACKERS] pgbench stuck with 100% cpu usage
Date
Msg-id CABOikdPhfXTypckMC1Ux6Ko+hKBWwUBA=EXsvamXYSg8M9J94w@mail.gmail.com
Whole thread Raw
Responses Re: [HACKERS] pgbench stuck with 100% cpu usage
List pgsql-hackers
Hello,

While running some tests, I encountered a situation where pgbench gets stuck in an infinite loop, consuming 100% cpu. The setup was:

- Start postgres server from the master branch
- Initialise pgbench
- Run pgbench -c 10 -T 100
- Stop postgres with -m immediate

Now it seems that pgbench gets stuck and it's state machine does not advance. Attaching it to debugger, I saw that one of the clients remain stuck in this loop forever.

               if (command->type == SQL_COMMAND)
                {
                    if (!sendCommand(st, command))
                    {
                        /*
                         * Failed. Stay in CSTATE_START_COMMAND state, to
                         * retry. ??? What the point or retrying? Should
                         * rather abort?
                         */
                        return;
                    }
                    else
                        st->state = CSTATE_WAIT_RESULT;
                }

sendCommand() returns false because the underlying connection is bad and PQsendQuery returns 0. Reading the comment, it seems that the author thought about this situation but decided to retry instead of abort. Not sure what was the rationale for that decision, may be to deal with transient failures?

The commit that introduced this code is 12788ae49e1933f463bc. So I am copying Heikki.

Thanks,
Pavan



--
 Pavan Deolasee                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

pgsql-hackers by date:

Previous
From: Etsuro Fujita
Date:
Subject: [HACKERS] Another oddity in handling of WCO constraints in postgres_fdw
Next
From: Yugo Nagata
Date:
Subject: Re: [HACKERS] Optional message to user when terminating/cancellingbackend