[英]Why does Perl reuse the same MySQL connection in this Munin script?
I have modified the script mysql_
from Munin, so that the function do_connect
looks like this: 我已经修改了Munin脚本mysql_
,所以函数do_connect
看起来像这样:
sub db_connect {
my $dsn = "$config{dsn};mysql_socket=$config{mysqlsocket};mysql_connect_timeout=5;";
return DBI->connect($dsn, $config{user}, $config{password}, {
RaiseError => 1,
PrintError => 0,
FetchHashKeyName => 'NAME_lc',
});
}
I have configured plugins-conf
to set different values for the socket reflected in the environment variable mysqlsocket
. 我已经配置了plugins-conf
来为环境变量mysqlsocket
反映的套接字设置不同的值。 So, each instance has its own value for env.mysqlsocket
. 因此,每个实例都有自己的env.mysqlsocket
值。 When I run my instances with 当我运行我的实例时
$ for i in a b c; do munin-run mysql_${i}_innodb_rows; done
then the first one that connects ( a
in this order) opens a connection which is used by the subsequent ones, instead of their sockets. 然后连接所述第一个( a
以该顺序)将打开,其通过随后的那些用于代替各自的插槽,一个连接。 The connection strings are correct, they really change. 连接字符串是正确的,它们确实发生了变化。
The DBI->connect
is not executed. 不执行DBI->connect
。 I can prove this by setting the socket filenames to non-existent files; 我可以通过将套接字文件名设置为不存在的文件来证明这一点; it reuses the same connection again. 它再次重用相同的连接。
I wonder, since these are independent processes of a symlinked script. 我想知道,因为这些是符号链接脚本的独立过程。
How can I force my Perl script to open a new connection anyway? 如何强制我的Perl脚本打开新连接呢?
使用手册:
$dsn->disconnect;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.