Skip to content

Deadlock Error in Magento 2 During High Concurrency: Serialization failure on cataloginventory_stock_item Table #39417

Description

@talsan74

Preconditions (*)

  1. Magento: 2.4.7
  2. PHP: 8.3
  3. RDS MYSQL: 8.0 16GB Memory

Steps to reproduce (*)

  1. Install Default Magento
  2. Cron for every 1 minitue
  3. Added 10k products
  4. Run Stress Test for 100 users using JMeter
  5. Trying to place order using graphql

Expected result (*)

  1. 100% will be placed

Actual result (*)

Out of 100 orders, a single-digit order is regularly missing. Resource metrics are fine. This issue only occurs during the stress test, not during manual execution. The logs are being retrieved in Magento.

main.ERROR: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction, query was: SELECT `si`.* FROM `cataloginventory_stock_item` AS `si` WHERE (item_id IN (4475, 4522, 4679, 8444, 8745)) FOR UPDATE

GraphQL (3:7)
    mutation {
       placeOrder(input: { cart_id: "Zsasfghssdfgghfghghjgs" }) {
         ^
       order {
 {"exception":"[object] (GraphQL\\Error\\Error(code: 0): SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction, query was: SELECT `si`.* FROM `cataloginventory_stock_item` AS `si` WHERE (item_id IN (4475, 4522, 4679, 8444, 8745)) FOR UPDATE at /var/www/html/vendor/webonyx/graphql-php/src/Error/Error.php:170)
[previous exception] [object] (Magento\\Framework\\DB\\Adapter\\DeadlockException(code: 1213): SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction, query was: SELECT `si`.* FROM `cataloginventory_stock_item` AS `si` WHERE (item_id IN (4475, 4522, 4679, 8444, 8745)) FOR UPDATE at /var/www/html/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php:672)
[previous exception] [object] (Zend_Db_Statement_Exception(code: 40001): SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction, query was: SELECT `si`.* FROM `cataloginventory_stock_item` AS `si` WHERE (item_id IN (4475, 4522, 4679, 8444, 8745)) FOR UPDATE at /var/www/html/lib/internal/Magento/Framework/DB/Statement/Pdo/Mysql.php:109)
[previous exception] [object] (PDOException(code: 40001): SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction at /var/www/html/lib/internal/Magento/Framework/DB/Statement/Pdo/Mysql.php:90)"} []

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area: CatalogComponent: CatalogIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Reported on 2.4.7Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions