lwp 模拟行锁堵塞 前端超时
2016-04-16 20:10
429 查看
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\n"; 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\n"; print "111111111111111111111111111111111111\n"; 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\n"; $dbh->rollback(); #just die if rollback is failing $c->render(text => "update failed" ); }; }; 行锁堵塞,前端超时
相关文章推荐
- 详细分析Node.js中的UDP模块
- jQuery自己定义绑定的魔法升级版
- JAVA bootstrap ClassLoader和JAVA核心API替换 《java -Xbootclasspath/p:F:\myinteger.jar MyIntegerTest》
- node初识
- Webpack教程二
- 拒绝javascript 模拟 只用CSS美化选择框
- H5动效的常见制作手法
- JS部分笔试题
- Three.js打造H5里的“3D全景漫游”秘籍
- WEB前端学习笔记 四
- 打造H5动感影集的爱恨情仇(动画性能篇)
- JavaScript 中定义变量时有无var声明的区别
- Webpack教程一
- JSP语法
- 深入理解JavaScript的闭包特性 如何给循环中的对象添加事件(转)
- 周日任务:了解bootstrap和后台管理系统
- jQuery中:first,:first-child,first()的使用区别
- 利用SharedPreferences对象进行读写
- CSS3 选择器
- windows环境安装nodejs