- 论坛徽章:
- 0
|
本帖最后由 hnwcr 于 2010-05-25 10:43 编辑
问题:爹进程如果不sleep 则程序立即异常,sleep的话只有第一个子进程正常,sleep时间到后,整个程序异常。
请教这是为什么?????? 关键部份的代码贴如下:
$oracle_dbh->{InactiveDestroy}=1; ##参考DBI文档,设成常连
foreach (0..4) ###生成测试5个进程分别处理表中5组数据。表中记录非常之多
{ my $pid=fork();
$oracle_dbh->{InactiveDestroy}=1;
if ($pid==0)
{ ##子进程
$oracle_dbh->{InactiveDestroy}=1;
my $sql_child= qq { select * from hiuinv1o.acc_fund_book
WHERE MOD(account_id,5)=}.$_; ###利用account字段按5取余把表中数据分为5个进程待处理的数据
print $sql_child."\n";
my $sth_child=$oracle_dbh->prepare($sql_child);#SQL语句
$sth_child->execute();
my @alt_cursor=(); ##初始化数组
my $seq_child=0;
while(@alt_cursor=$sth_child->fetchrow_array)
{
print $$."\n"; ###有数据就随便打出进程编号
}
exit(0);
}
elsif ($pid==-1) {print ("fork error\n");
exit(-1);
}
else ###爹进程
{sleep 8; ##把这个地方去掉,程序立即结束。保留的话第一个子进程在8秒内运行正常,超过8秒后整个程序异常。
$oracle_dbh->{InactiveDestroy}=1;}
}
while(waitpid(-1, WNOHANG)!=-1) {
my $es=`ps -ef|grep owe`;
print $es."\n";
}
my $es=`ps -ef|grep owe`;
print $es."\n";
错误 信息如下:
child 4895000 is running!
select * from hiuinv1o.acc_fund_book
WHERE MOD(account_id,5)=0
打印第一个子进程的编号无数行
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
。。。。。。。。。。。。。。。。。。。。
sleep 8后。。。。。。。。。。。。。。。。。。。
child 6267266 is running!
select * from hiuinv1o.acc_fund_book
WHERE MOD(account_id,5)=1
DBD::Oracle::st execute failed: ORA-03106: fatal two-task communication protocol error (DBD ERROR: OCIStmtExecute) [for Statement " select * from hiuinv1o.acc_fund_book
WHERE MOD(account_id,5)=1"] at owe.pl line 171.
DBD::Oracle::st fetchrow_array failed: ORA-03115: unsupported network datatype or representation (DBD ERROR: OCIStmtFetch) [for Statement " select * from hiuinv1o.acc_fund_book
WHERE MOD(account_id,5)=0"] at owe.pl line 174.
DBD::Oracle::st fetchrow_array failed: ERROR no statement executing (perhaps you need to call execute first) [for Statement " select * from hiuinv1o.acc_fund_book
WHERE MOD(account_id,5)=1"] at owe.pl line 174.
###################################
###################################
child 3494328 is running!
select * from hiuinv1o.acc_fund_book
WHERE MOD(account_id,5)=2
DBD::Oracle::db prepare failed: ORA-03113: end-of-file on communication channel (DBD ERROR: error possibly near <*> indicator at char 15 in ' select * from <*>hiuinv1o.acc_fund_book
WHERE MOD(account_id,5)=2') [for Statement " select * from hiuinv1o.acc_fund_book
WHERE MOD(account_id,5)=2"] at owe.pl line 170.
Can't call method "execute" on an undefined value at owe.pl line 171.
###################################
child 6324638 is running!
select * from hiuinv1o.acc_fund_book
WHERE MOD(account_id,5)=3
DBD::Oracle::db prepare failed: ORA-03135: connection lost contact (DBD ERROR: error possibly near <*> indicator at char 15 in ' select * from <*>hiuinv1o.acc_fund_book
WHERE MOD(account_id,5)=3') [for Statement " select * from hiuinv1o.acc_fund_book
WHERE MOD(account_id,5)=3"] at owe.pl line 170.
Can't call method "execute" on an undefined value at owe.pl line 171.
###################################
child 6402494 is running!
select * from hiuinv1o.acc_fund_book
WHERE MOD(account_id,5)=4
DBD::Oracle::db prepare failed: ORA-03135: connection lost contact (DBD ERROR: error possibly near <*> indicator at char 15 in ' select * from <*>hiuinv1o.acc_fund_book
WHERE MOD(account_id,5)=4') [for Statement " select * from hiuinv1o.acc_fund_book
WHERE MOD(account_id,5)=4"] at owe.pl line 170.
Can't call method "execute" on an undefined value at owe.pl line 171.
###################################
###################################
wcr 242108 2965682 2 16:13:59 pts/19 0:00 perl owe.pl
wcr 6402496 242108 0 16:14:36 pts/19 0:00 grep owe
###################################
wcr 242108 2965682 2 16:13:59 pts/19 0:00 perl owe.pl
wcr 6324640 242108 0 16:14:36 pts/19 0:00 grep owe
###################################
wcr 242108 2965682 2 16:13:59 pts/19 0:00 perl owe.pl
wcr 3494330 242108 0 16:14:36 pts/19 0:00 grep owe
###################################
wcr 242108 2965682 3 16:13:59 pts/19 0:00 perl owe.pl
wcr 6267268 242108 0 16:14:37 pts/19 0:00 grep owe
###################################
wcr 242108 2965682 3 16:13:59 pts/19 0:00 perl owe.pl
wcr 4895002 242108 0 16:14:37 pts/19 0:00 grep owe
###################################
wcr 242108 2965682 3 16:13:59 pts/19 0:00 perl owe.pl
wcr 4895004 242108 0 16:14:37 pts/19 0:00 grep owe |
|