DBD::Sybase and fork() in Perl 5.8.7



I am trying to connect to one Sybase database in a parent process and
other Sybase database in a child process. I was able to do this under
Perl 5.6 but the same code no longer works under Perl 5.8.7. Here is a
sample program which replicates the problem:

===============================================================
#!/opt/perl/bin/perl -w

use DBI;
use DBD::Sybase;

$|=1;

unless ($dbh =
DBI->connect("dbi:Sybase:server=$ENV{DBSVR};database=$ENV{DBNAME};loginTimeout=10",
$ENV{DBLOG}, "XXXXX"))
{
print STDERR ("Failure connecting\n");
exit(1);
}

$sth = $dbh->prepare('select @@spid');
$sth->execute;

@row = $sth->fetchrow_array();
$sth->finish;
$sth = undef;
$dbh->disconnect || warn $dbh->errstr;
$dbh = undef;

printf ("PID %d SPID %d\n", $$, $row[0]);

$pid = fork();

if ($pid == 0)
{
unless ($dbh2 =
DBI->connect("dbi:Sybase:server=$ENV{DBSVR2};database=$ENV{DBNAME2};loginTimeout=10",
$ENV{DBLOG2}, "XXXXX"))
{
print STDERR ("Failure connecting\n");
exit(1);
}

$sth2 = $dbh2->prepare('select @@spid');
$sth2->execute;

@row2 = $sth2->fetchrow_array();
$sth2->finish;
$sth2 = undef;
$dbh2->disconnect || warn $dbh2->errstr;

printf ("Child PID %d SPID %d\n", $$, $row2[0]);
}
else
{
waitpid($pid, 0);
}

Running this code generates the following output:

PID 6454 SPID 315
OpenClient message: LAYER = (1) ORIGIN = (1) SEVERITY = (1) NUMBER =
(151)
Message String: ct_cancel(): user api layer: external error: A
connection to the server must exist on the connection structure before
this routine can be called.
DBI
connect('server=MYSERVER;database=bubba1;loginTimeout=10','main1',...)
failed: OpenClient message: LAYER = (1) ORIGIN = (2) SEVERITY = (2)
NUMBER = (63)
Server MYSERVER, database
Message String: ct_connect(): user api layer: internal Client Library
error: Read from the server has timed out.
at ./test3.pl line 29
Failure connecting

===============================================================

Could someone help me figure out why the child process cannot connect?

Thanks for any and all help,

Eric

.



Relevant Pages

  • Re: DBD::Sybase and fork() in Perl 5.8.7
    ... other Sybase database in a child process. ... connection to the server must exist on the connection structure before ... Server MYSERVER, database ... Could someone help me figure out why the child process cannot connect? ...
    (perl.dbi.users)
  • Re: parallel child processes not working properly
    ... Each child process has a different ... has a forever loop so that it never exits unless killed or reboot ... occured at server and then it tries to reconnect. ...
    (comp.lang.perl.misc)
  • Re: problem about CLOSE_WAIT
    ... what exactly that race condition is needs to be determined. ... One common problem is that multiple connections are sent to the same child process. ... the next child process cannot close the connection when it is done, ... connection is closed only when the last socket is closed. ...
    (comp.unix.programmer)
  • DBD::PgSPI crashes the database server (SIGSEGV)?
    ... I have tried to use "plperlu" to write server functions to encapsulate ... child process (PID 4339) was terminated by signal 11 ... terminating any other active server processes ...
    (comp.lang.perl.modules)
  • Re: Linux is so cool!
    ... shell command the X server runs as a child process to the shell. ... than switching to an open konsole window and typing powerdown... ... I guess with linux, there are often so many ways to skin the proverbial ...
    (Fedora)