Bug #63365 [Opn]: pg_send_query() blocks on queries to other connections.
| From: | mbeccati@php.net | Date: | Wed, 05 Jun 2013 13:48:32 +0000 |
| Subject: | Bug #63365 [Opn]: pg_send_query() blocks on queries to other connections. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-179343@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63365&edit=1
ID: 63365
Updated by: mbeccati@php.net
Reported by: chris at ctgameinfo dot com
Summary: pg_send_query() blocks on queries to other
connections.
Status: Open
Type: Bug
Package: PostgreSQL related
Operating System: FreeBSD (probably irrevelant)
PHP Version: 5.4.8
Block user comment: N
Private report: N
New Comment:
This won't block:
<?php
for($i=1;$i<=10;$i++)
{
echo "Interation $i\n";
$dbconn[$i] = pg_connect("dbname=postgres", PGSQL_CONNECT_FORCE_NEW);
// Will block in the second loop interation
pg_send_query($dbconn[$i], "select pg_sleep(5)");
echo "Last error: '".pg_last_error($dbconn[$i])."'\n";
}
?>
So the issue only happens when you "overwrite" an existing connection
Previous Comments:
------------------------------------------------------------------------
[2012-10-28 16:24:28] chris at ctgameinfo dot com
Modified test script with requested pg_last_error output.
-------
<?php
for($i=1;$i<=10;$i++)
{
echo "Interation $i\n";
$dbconn = pg_connect("user=cstdenis dbname=postgres",
PGSQL_CONNECT_FORCE_NEW);
// Will block in the second loop interation
pg_send_query($dbconn, "select pg_sleep(5);");
echo "Last error: '".pg_last_error($dbconn)."'\n";
}
?>
Output:
-------
Interation 1
Last error: ''
Interation 2
Last error: ''
Interation 3
Last error: ''
Interation 4
Last error: ''
Interation 5
Last error: ''
Interation 6
Last error: ''
Interation 7
Last error: ''
Interation 8
Last error: ''
Interation 9
Last error: ''
Interation 10
Last error: ''
------------------------------------------------------------------------
[2012-10-28 13:57:36] felipe@php.net
Please, check out the return from pg_last_error($dbconn); after the pg_send_query() call and post
the result in there.
------------------------------------------------------------------------
[2012-10-25 20:58:13] chris at ctgameinfo dot com
Description:
------------
If I open a connection and send a long running query with pg_send_query, then
open a second connection and try to send a query over the second connection with
pg_send_query it will block on the first connection's query not being complete
Test script:
---------------
<?php
for($i=1;$i<=10;$i++)
{
echo "Interation $i\n";
$dbconn = pg_connect("user=pgsql dbname=postgres", PGSQL_CONNECT_FORCE_NEW);
// Will block in the second loop interation
pg_send_query($dbconn, "select pg_sleep(5);");
}
?>
Expected result:
----------------
pg_send_query should only block on incomplete queries on the same connection.
Actual result:
--------------
pg_send_query blocks on incomplete queries on any connection.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63365&edit=1