Question

When sending the status request pg_connection_busy(), does the request discriminate between "connection busy" and "server busy" ?

In other words, a server has 100 allowed connections, with one of them applied to the current script. All 100 connections simultaneously send a query, with 99 of them requiring 2+ seconds of processing time, (theoretically putting the server into a maxed out state thus making it "busy"). One of those 100 requests was a pg_server_busy() request. Would the response be True or False?

Was it helpful?

Solution

pg_connection_busy() basically calls libpq's PQconsumeInput() followed by PQisBusy(), both are documented in Asynchronous Command Processing.

This has nothing to do with the server being busy overall with other connections. Also it doesn't send anything to it, query or otherwise, it's purely a local condition about the buffering of the incoming data when retrieving results asynchronously.

Unfortunately the example given by php's documentation is misleading. It calls pg_connection_busy() on a new connection without any asynchronous query running, which doesn't make any sense.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top