php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80319 No error if the lock time exceeds innodb_lock_wait_timeout
Submitted: 2020-11-05 08:22 UTC Modified: 2020-12-03 07:03 UTC
From: ngyuki dot jp at gmail dot com Assigned:
Status: Closed Package: PDO MySQL
PHP Version: 7.4.12 OS: Alpine Linux v3.12
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ngyuki dot jp at gmail dot com
New email:
PHP Version: OS:

 

 [2020-11-05 08:22 UTC] ngyuki dot jp at gmail dot com
Description:
------------
If the following conditions are met, No error if the lock time exceeds innodb_lock_wait_timeout.

- ATTR_EMULATE_PREPARES = false
- WHERE is not specified

MySQL(8.0.22) contains the following data.

    create table t ( id int not null primary key auto_increment );
    insert into t values (1);

Run the test script as follows.

    (php test.php >/dev/null) & (sleep 1 && php test.php)

Setting ATTR_EMULATE_PREPARES = true or WHERE id = 1 results in an error, as expected.

Test script:
---------------
<?php
$pdo = new PDO('mysql:host=mysql;port=3306;dbname=test', 'test', 'pass', [
    PDO::ATTR_EMULATE_PREPARES => false,
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);

$pdo->beginTransaction();

$stmt = $pdo->query('SELECT id FROM t FOR UPDATE');
$rows = $stmt->fetchAll();
var_dump([$stmt->errorCode(), $stmt->errorInfo(), $rows]);

sleep(5);

Expected result:
----------------
SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction

Actual result:
--------------
array(3) {
  [0]=>
  string(5) "00000"
  [1]=>
  array(3) {
    [0]=>
    string(5) "00000"
    [1]=>
    NULL
    [2]=>
    NULL
  }
  [2]=>
  array(0) {
  }
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-11-05 08:26 UTC] ngyuki dot jp at gmail dot com
This test specifies innodb_lock_wait_timeout=1 in MySQL.
 [2020-11-05 08:28 UTC] nikic@php.net
-Status: Open +Status: Feedback
 [2020-11-05 08:28 UTC] nikic@php.net
Please try the upcoming PHP 7.4.13 release. A lot of bugs relating to this issue will be fixed in this release.
 [2020-11-15 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2020-12-03 07:03 UTC] ngyuki dot jp at gmail dot com
-Status: No Feedback +Status: Closed
 [2020-12-03 07:03 UTC] ngyuki dot jp at gmail dot com
Confirmed that this has been fixed in PHP 7.4.13.
Thank you!
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Oct 23 20:03:34 2021 UTC