执行存储过程时 PHP Apache 崩溃

标签 php mysql apache stored-procedures wamp

问题

当我执行以下代码时(我正在调用一个带有 5 个 IN 参数和 1 个 OUT 参数的存储过程)

$conn->query("SET @res = ''");

$mysqli=$conn;
if (!($stmt = $mysqli->prepare("CALL retrieve_matches(5,3, 16, 2, false, @res)"))) {
    echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
}

if (!$stmt->execute()) {
    echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
}

do {
    if ($res = $stmt->get_result()) { //Apache crash on this call
        printf("---\n");
        var_dump(mysqli_fetch_all($res));
        mysqli_free_result($res);
    } else {
        if ($stmt->errno) {
            echo "Store failed: (" . $stmt->errno . ") " . $stmt->error;
        }
    }
} while ($stmt->more_results() && $stmt->next_result());

apache 因错误而崩溃:

AH00428: Parent: child process 9628 exited with status 255 -- Restarting.

我尝试了什么

  1. 此代码运行良好,并且可以正确返回结果:
$conn->query("SET @res = ''");
$res=$conn->query("CALL retrieve_matches(5,3, 16, 2, false, @res)");
var_dump($res->fetch_assoc());

注意:如果我只是更改存储过程的输入中的数字,则上述使 Apache 崩溃的相同代码可以正常工作,例如:

if (!($stmt = $mysqli->prepare("CALL retrieve_matches(5,6, 16, 2, false, @res)"))) {
  1. 从 MySQl 工作台尝试过,两个调用都运行良好。
  2. 我在 WIN7 Enterprise 64b 上使用 WAMP 64b,我尝试使用 WAMP 32b 但遇到了同样的问题。
  3. 我检查了windows事件,发现httpd.exe崩溃是由php5ts.dll引起的
  4. 如果你在谷歌上搜索“httpd.exe php5ts.dll”你会发现很多人遇到这个问题。但我没有找到 WAMP 的解决方案...
  5. 用 AMPPS 试过,问题一模一样

PHP 错误日志

[10-Jul-2015 15:30:03 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:/Program Files/wamp/bin/php/php5.5.12/ext/php_ldap.dll' - Impossibile trovare il modulo specificato.

 in Unknown on line 0

[10-Jul-2015 15:30:04 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:/Program Files/wamp/bin/php/php5.5.12/ext/php_intl.dll' - Impossibile trovare il modulo specificato.

APACHE 错误日志:

[Tue Jul 14 15:02:13.038276 2015] [mpm_winnt:notice] [pid 7044:tid 404] AH00428: Parent: child process 9448 exited with status 255 -- Restarting.
[Tue Jul 14 15:02:13.324305 2015] [mpm_winnt:notice] [pid 7044:tid 404] AH00455: Apache/2.4.9 (Win32) PHP/5.5.12 configured -- resuming normal operations
[Tue Jul 14 15:02:13.329306 2015] [mpm_winnt:notice] [pid 7044:tid 404] AH00456: Apache Lounge VC11 Server built: Mar 16 2014 12:13:13
[Tue Jul 14 15:02:13.329306 2015] [core:notice] [pid 7044:tid 404] AH00094: Command line: 'C:\\Program Files\\wamp\\bin\\apache\\apache2.4.9\\bin\\httpd.exe -d C:/Program Files/wamp/bin/apache/apache2.4.9'
[Tue Jul 14 15:02:13.352308 2015] [mpm_winnt:notice] [pid 7044:tid 404] AH00418: Parent: Created child process 3140
[Tue Jul 14 15:02:14.528388 2015] [mpm_winnt:notice] [pid 3140:tid 332] AH00354: Child: Starting 64 worker threads.

我真的迷路了,我应该在哪里寻找问题? 非常感谢您的帮助

编辑

我意识到存储过程“retrieve_matches”正在根据更改的值调用不同的存储过程。我调试了导致 Apache 崩溃的存储过程“retrieve_standalone”。此过程正在执行选择/插入,我检查并正确插入。 但是在“retrieve_standalone”中,我以一种奇怪的方式使用光标:

declare bNoMoreRows bool default false;
declare tmp_cursor cursor for
    select comp_id from to_match; -- to_match is a temporary table
declare continue handler for not found set bNoMoreRows := true;

如果我不打开光标

open tmp_cursor;

一切正常!!所以我想我现在找到了问题:我该如何解决?

最佳答案

如果每次运行短脚本时 php5ts.dll 或 apache 的任何其他部分都以可重现的方式崩溃,那么您很可能遇到了 php 中的错误。尤其是如果您使用从 php.net 下载的最新 php 版本运行最新的 apache,您很有可能获得 PHP 团队的支持。所以请通读https://bugs.php.net/how-to-report.php ,看看在没有 apache(在 cli 上使用 php.exe 的单独脚本中)和 generate a backtrace 的情况下运行脚本时是否可以重现崩溃然后您可以将其作为错误提交。

有时可以解决此类错误,但很少从脚本的上下文中修复。 PHP 永远不应该让网络服务器崩溃,如果它可以重现地发生这种情况,应该提交一个错误以便修复它

关于执行存储过程时 PHP Apache 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31279884/

相关文章:

php - 使用 PHP 从任何选择查询中提取表名

php - 将自定义过滤器添加到用户管理列表

javascript - dropzone.js php 上传不起作用

mysql - : before a value in sql mean? 是什么意思

regex - ^ 字符无法在 htaccess 中进行 mod 重写

php - 更新配置文件时执行 INSERT

php - PHP 中不区分大小写的查询不起作用

mysql查询批量插入导致序列间隙

apache - 从多个 tomcat 网站的 url 隐藏名称和端口

Apache 2 站点可用配置