私はPerl fork managerとDBIを試しました。 しかし、エラーが発生しましたDBD :: mysql :: stの実行に失敗しました:クエリ中にMySQLサーバーへの接続が失われました。ここでPerlの分岐した子からデータベースを照会できないのはなぜですか?
サンプルコード:私は高い値に低いとのクエリ(私はint型の10Kレコードをスピッティングしている)
use Parallel::ForkManager;
my $pm = new Parallel::ForkManager(50);
my $db = krish::DB->new or die $!; # its has all connection details
while ($low < $high ) {
# Some value manipulation
my $pid = $pm->start and next;
#db_execution returns execution
while (my $sth = db_execution ($db, $low , $high)) {
...
#fetch row operation
...
}
$pm->finish;
}
sub db_execution {
...
my $dbh = $db->connect('students') or die $!;
my $sth = $dbh->prepare($sql) or die "$!:" . $dbh->errstr;
$sth->execute or die "$!:" . $sth->errstr;
...
}
同じコードが出て並列処理で実行されていることを確認します。どうした? 解決方法これはですか?
すみません。私は誤ってコミュニティのwikiに変換しました – joe