Hi,
i'm using firebird 1.5.1 on a linux machine with a php script
I'm using a query in loop and go through all records to do some operations
in the middle of the script i fork(); to do other things
When i return to the parent process i try to make one update and i get
the following error
[nativecode=Unable to complete network request to host "127.0.0.1".
Error writing data to the connection. Broken pipe]
And continue the loop of the records of the query.
It apears that the fork and the wait from pcntl closes the sockets to
the database.
Is this a regular beaviour ? How can it be solved ?
I'm using Pear DB for database access.
Thank you in advance
Rui Francisco
user@domain.invalid wrote:
I'm using a query in loop and go through all records to do some
operations in the middle of the script i fork(); to do other things
When i return to the parent process i try to make one update and i
get the following error [nativecode=Unable to complete network
request to host "127.0.0.1". Error writing data to the connection.
Broken pipe]
That would be a fairly well known issue with PHP. You're running into
the same thing we encountered about 2 years ago. What happens is that
your child process is closing the mysql connection as part of its
standard PHP cleanup procedures, leaving the parent with a broken
connection.
I'd recommend provisioning a method so that your child makes its own new
connection, and does not use the parent's connection at all. Since all
php scripts clean up before exiting, you need to make sure all resources
in use by the child are not needed by the parent after the child exits.
--
Shaun M. Thomas INN Database Administrator
Phone: (309) 743-0812 Fax : (309) 743-0830
Email: sthomas@townnews.com Web : www.townnews.com
I'm using a query in loop and go through all records to do some
operations in the middle of the script i fork(); to do other things
When i return to the parent process i try to make one update and i
get the following error [nativecode=Unable to complete network
request to host "127.0.0.1". Error writing data to the connection.
Broken pipe]That would be a fairly well known issue with PHP. You're running into
the same thing we encountered about 2 years ago. What happens is that
your child process is closing the mysql connection as part of its
standard PHP cleanup procedures, leaving the parent with a broken
connection.I'd recommend provisioning a method so that your child makes its own new
connection, and does not use the parent's connection at all. Since all
php scripts clean up before exiting, you need to make sure all resources
in use by the child are not needed by the parent after the child exits.
Or just use persistent resources (i.e.: mysql_pconnect() )
-Sara
The child process doesn't use any database connection, just to run some
shell scripts, but it closes the connection anyway.
I initialy used PEAR DB and then _pconnect functions but the result is
the same.
Was the bug solved two years ago ?
How was it solved ?
Thank you
Rui Francisco
Shaun Thomas wrote:
user@domain.invalid wrote:
I'm using a query in loop and go through all records to do some
operations in the middle of the script i fork(); to do other things
When i return to the parent process i try to make one update and i
get the following error [nativecode=Unable to complete network
request to host "127.0.0.1". Error writing data to the connection.
Broken pipe]That would be a fairly well known issue with PHP. You're running into
the same thing we encountered about 2 years ago. What happens is that
your child process is closing the mysql connection as part of its
standard PHP cleanup procedures, leaving the parent with a broken
connection.I'd recommend provisioning a method so that your child makes its own new
connection, and does not use the parent's connection at all. Since all
php scripts clean up before exiting, you need to make sure all resources
in use by the child are not needed by the parent after the child exits.
user@domain.invalid wrote:
The child process doesn't use any database connection, just to run some
shell scripts, but it closes the connection anyway.
You still don't get it. As a fork, the child process has all of the
same resources as the parent before the fork occurred. When the child
exits, it will close those resources, leaving the parent high and dry.
I initialy used PEAR DB and then _pconnect functions but the result is
the same.
Not sure why that would be. Maybe the CLI doesn't honor _pconnect based
functions, since pconnect was originally designed for keeping
connections persistent across server processes.
Was the bug solved two years ago ?
This is not a bug. It is a natural part of how PHP cleans up after
itself. There are many ways to circumvent this, but are left as an
exercise for the programmer. In our case, we did a test on the
connection at all times before using it, and reconnected if the resource
was ever closed or invalid; your mileage may vary.
--
Shaun M. Thomas INN Database Administrator
Phone: (309) 743-0812 Fax : (309) 743-0830
Email: sthomas@townnews.com Web : www.townnews.com