- 論壇徽章:
- 0
|
本帖最后由 hnwcr 于 2010-05-25 10:43 編輯
問題:爹進程如果不sleep 則程序立即異常,sleep的話只有第一個子進程正常,sleep時間到后,整個程序異常。
請教這是為什么?????? 關鍵部份的代碼貼如下:
$oracle_dbh->{InactiveDestroy}=1; ##參考DBI文檔,設成常連
foreach (0..4) ###生成測試5個進程分別處理表中5組數(shù)據(jù)。表中記錄非常之多
{ 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取余把表中數(shù)據(jù)分為5個進程待處理的數(shù)據(jù)
print $sql_child."\n";
my $sth_child=$oracle_dbh->prepare($sql_child);#SQL語句
$sth_child->execute();
my @alt_cursor=(); ##初始化數(shù)組
my $seq_child=0;
while(@alt_cursor=$sth_child->fetchrow_array)
{
print $$."\n"; ###有數(shù)據(jù)就隨便打出進程編號
}
exit(0);
}
elsif ($pid==-1) {print ("fork error\n");
exit(-1);
}
else ###爹進程
{sleep 8; ##把這個地方去掉,程序立即結(jié)束。保留的話第一個子進程在8秒內(nèi)運行正常,超過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
打印第一個子進程的編號無數(shù)行
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
。。。。。。。。。。。。。。。。。。。。
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 |
|