jrhmpt01:/root/async# cat a2.pl
use LWP::UserAgent;
use utf8;
use DBI;
use POSIX;
use HTTP::Date qw(time2iso str2time time2iso time2isoz);
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
$ua->agent("Mozilla/8.0");
$time1=time2iso(time());
print "$time1 is $time1
";
my $response = $ua->get('http://120.55.118.6:3000/api/update?id=1');
if ($response->is_success) {
print $response->decoded_content; # or whatever
}else{print $response->decoded_content; };
$time2=time2iso(time());
print "$time2 is $time2
";
print "111111111111111111111111111111111111
";
jrhmpt01:/root/async# perl a2.pl
$time1 is 2016-04-16 20:03:08
500 read timeout
$time2 is 2016-04-16 20:03:18
111111111111111111111111111111111111
查看接口的事务情况:
get '/api/update' => sub {
my $dbName = 'oadb';
my $dbUser = 'query';
my $dbUserPass = 'xxx';
my $dbh = DBI->connect("dbi:Oracle:$dbName", $dbUser, $dbUserPass,{
RaiseError => 1,
AutoCommit => 0
}) or die "can't connect to database " ;
my $c = shift;
my $id=$c->param('id');
eval{
$dbh->do("update query.test set id=100 where id =$id") or $!;
$dbh->commit();
$c->render(text => "update successed" );
};
if( $@ ) {
#warn "Database error: $DBI::errstr
";
$dbh->rollback(); #just die if rollback is failing
$c->render(text => "update failed" );
};
};
行锁堵塞,前端超时