We just upgraded one of our database servers from Oracle 12.2.0.1 to
19.15.0 and one our perl programs is behaving differently. We are running
with RedHat 8.4 using Perl v5.26.3 and the latest DBD::Oracle and DBI from
cpan.

Under 19c, a forked child hangs on exit if the parent has (or had) an
oracle connection where the connection handle is a global (using 'our').
This does not happen if the connection handle is a local (declared with
'my'). When running against a 12c database, with DBD::Oracle using 12c
libraries, the child process exits normally regardless of how the variable
is 'declared'.

Note also that this issue does not happen if the child exec's another
program.

The block of code below exhibits the issue in our environment. This is just
a simplification. The real code uses packages and so the connection handle
needs to be a global.

Any help appreciated.

use strict;
use warnings;

use DBI;

# If $dbh declared with my, this works witn 19c
# otherwise, exit in child below never returns
our $dbh = DBI->connect('dbi:Oracle:ORCL', 'scott', 'tiger',
                       { RaiseError => 1, AutoCommit => 0, PrintError
=> 0, InactiveDestroy  => 1 });

print "Connected to db\n";
$dbh->disconnect;
#undef $dbh;   # Child process exits normally if this uncommented

my $pid;
$pid = fork;

if( $pid == 0 ) {
    print "This is child process\n";
    print "Child process exiting now\n";
    exit 0;     # Never returns if $dbh is a global
}

print "This is parent process and child ID is $pid\n";
print "Parent Waiting on child\n";
my $chldPid = wait;
print "Parent done. Child pid $chldPid has completed\n";

exit 0;

Reply via email to