简体   繁体   English

当mysql服务器不响应时register_shutdown_function不起作用

[英]register_shutdown_function not working when the mysql server doesn't respond

I'm trying to execute the register_shutdown_function when Zend_Db (PDO_MYSQL) can't reach the mysql server 10.0.0.36 but it hangs 30 seconds and then shows the next error: 当Zend_Db(PDO_MYSQL)无法到达mysql服务器10.0.0.36但它挂起30秒 ,然后显示下一个错误时,我正在尝试执行register_shutdown_function

Warning: PDO::__construct() [pdo.--construct]: [2002] Se produjo un error durante el intento de conexión ya que la par (trying to connect via tcp://10.0.0.36:3306) in C:\\AppServ\\php5\\pear\\Zend\\Db\\Adapter\\Pdo\\Abstract.php on line 129 警告:PDO :: __ construct()[pdo .-- construct]:[2002]在C语言中尝试生成错误消息(尝试通过tcp://10.0.0.36:3306进行连接):第129行的\\ AppServ \\ php5 \\ pear \\ Zend \\ Db \\ Adapter \\ Pdo \\ Abstract.php

Fatal error: Maximum execution time of 5 seconds exceeded in C:\\AppServ\\php5\\pear\\Zend\\Db\\Adapter\\Pdo\\Abstract.php on line 129 致命错误:第129行的C:\\ AppServ \\ php5 \\ pear \\ Zend \\ Db \\ Adapter \\ Pdo \\ Abstract.php中超出了5秒的最大执行时间

Hangs 30 seconds but I have a set_time_limit(5). 挂30秒,但我有一个set_time_limit(5)。 Normally the shutdown function catchs all errors, FATAL ERROR inclusives, only fails in this case. 通常情况下,关闭功能会捕获所有错误,包括致命错误在内,仅在这种情况下才会失败。

What's going on? 这是怎么回事? How can I make the shutdown function fire, or the 5s time limit to be observed? 如何使关机功能启动或遵守5秒的时间限制?

This worked in Zend_Db: 这在Zend_Db中起作用:

'adapter' => 'PDO...',
'params' => array(
    'username' => '...',
     //...
    'driver_options' => array(PDO::ATTR_TIMEOUT, 5)
 );

Now it doesn't hang for 30 seconds, and the shutdown_function works again. 现在它不会挂起30秒钟,并且shutdown_function可以再次工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM