Mombu the Php Forum

Go Back   Mombu the Php Forum > Php > pg_connect locking / hangs if another pg_connect run in the browser
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 22nd October 11:59
pkdouyk
External User
 
Posts: 1
Default pg_connect locking / hangs if another pg_connect run in the browser



Hi

A very strange case - pg_connect hangs if another pg_connects runs on
the browser already.

I have a PHP script that connect to postgres db and does some inserts.
when I launch this script in two browser windows simultaneously, the
2nd launch hangs, until the 1st terminates processing.

I thought it has something to do with DB locks, but that's not it -
it's the pg_connect itself.

Here's the shortest version of the script. When run standalone - all
is well; when run in parallel with itself - hangs.

<?php

$host="localhost";
$port="5432";
$dbname="xxx";
$dbuser="xxx";
$dbpass="xxx";
$conn_string = "host=$host port=$port dbname=$dbname user=$dbuser
password=$dbpass";

$conn = pg_connect($conn_string) or die ("error connecting to the
db");

sleep (30); // sleep 30 represents the amount of later work I have in
the script.

?>

as explained, the 2nd launch of this script is locked until the 1st
iteration terminates and then proceeds normally. in this example the
locking time is exactly 30 seconds as figured in the script.

I tried pg_pconnect too, as well as the FORCE_NEW directive - without
help.

Any advise would be greatly appreciated.

-pkd
  Reply With Quote


 


Reply


Thread Tools
Display Modes




666