Skip to content

Queue Management Issue (DB MQ) #37559

Closed
Closed
@makkoff

Description

@makkoff

Preconditions and environment

  • Magento Cloud 2.4.6
  • Configured slave connection with DB (default at Magento Cloud version)

Steps to reproduce

Note: Can reproduce this issue only at magneto cloud staging environment since there we use slave connection to the DB.

  1. Proceed to checkout
  2. Click on "Place Order" button

Expected result

The order was placed and the inventory.reservations.updateSalabilityStatus queue was successfully added

Actual result

Getting the error:
image

the inventory.reservations.updateSalabilityStatus queue fails because the \Magento\MysqlMq\Model\ResourceModel\Queue::saveMessage returns 0 instead of the last insert id(message id).

I added a rewrite for Magento\ResourceConnections\DB\Adapter\Pdo\MysqlProxy to log the last insert IDs of slave and master connections:

image

And here is the result:
[2023-05-30T12:47:36.737265+00:00] db_queue_logger.DEBUG: CONNECTIONS LOG: [] [] [2023-05-30T12:47:36.737307+00:00] db_queue_logger.DEBUG: MASTER Connection last insert ID - 9312 [] [] [2023-05-30T12:47:36.737347+00:00] db_queue_logger.DEBUG: MASTER Connection last insert ID with "queue" table - 9312 [] [] [2023-05-30T12:47:36.737387+00:00] db_queue_logger.DEBUG: SLAVE Connection last insert ID - 0 [] [] [2023-05-30T12:47:36.737425+00:00] db_queue_logger.DEBUG: SLAVE Connection last insert ID with "queue" table - 0

Additional information

DB query log:
...

     2023-05-25 15:04:45
       QUERY
         SQL: INSERT  INTO `queue_message_status` (`queue_id`,`message_id`,`status`) VALUES (?, ?, ?)
   BIND: array (
 0 => '44',
 1 => '0',
 2 => 2,
) 
  TIME: 0.0011
TRACE: #1 Magento\Framework\DB\Logger\File[Magento\Framework\DB\Logger\LoggerAbstract]#00000000000001300000000000000000#->getStats('query', 'INSERT  INTO `qu...', array(44, 0, 2), NULL) called at [vendor/magento/framework/DB/Logger/File.php:67]
#2 Magento\Framework\DB\Logger\File#00000000000001300000000000000000#->logStats('query', 'INSERT  INTO `qu...', array(44, 0, 2), NULL) called at [vendor/magento/framework/DB/Logger/LoggerProxy.php:152]
#3 Magento\Framework\DB\Logger\LoggerProxy#000000000000010c0000000000000000#->logStats('query', 'INSERT  INTO `qu...', array(44, 0, 2)) called at [vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:597]
#4 Magento\Framework\DB\Adapter\Pdo\Mysql\Interceptor[Magento\Framework\DB\Adapter\Pdo\Mysql]#00000000000010830000000000000000#->_query('INSERT  INTO `qu...', array(44, 0, 2)) called at [vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:634]
#5 Magento\Framework\DB\Adapter\Pdo\Mysql\Interceptor[Magento\Framework\DB\Adapter\Pdo\Mysql]#00000000000010830000000000000000#->query('INSERT  INTO `qu...', array(44, 0, 2)) called at [vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:2125]
#6 Magento\Framework\DB\Adapter\Pdo\Mysql\Interceptor[Magento\Framework\DB\Adapter\Pdo\Mysql]#00000000000010830000000000000000#->insertArray('queue_message_st...', array('queue_id', 'message_id', 'status'), array(array(44, 0, 2)), 0) called at [vendor/magento/module-resource-connections/DB/Adapter/Pdo/MysqlProxy.php:609]
#7 Magento\ResourceConnections\DB\Adapter\Pdo\MysqlProxy\Interceptor[Magento\ResourceConnections\DB\Adapter\Pdo\MysqlProxy]#000000000000010f0000000000000000#->insertArray('queue_message_st...', array('queue_id', 'message_id', 'status'), array(array(44, 0, 2))) called at [vendor/magento/module-mysql-mq/Model/ResourceModel/Queue.php:98]
#8 Magento\MysqlMq\Model\ResourceModel\Queue#000000000000140f0000000000000000#->linkMessagesWithQueues(array(0), array('inventory.reserv...')) called at [vendor/magento/module-mysql-mq/Model/ResourceModel/Queue.php:72]
#9 Magento\MysqlMq\Model\ResourceModel\Queue#000000000000140f0000000000000000#->linkQueues(0, array('inventory.reserv...')) called at [vendor/magento/module-mysql-mq/Model/QueueManagement.php:89]
#10 Magento\MysqlMq\Model\QueueManagement#00000000000014110000000000000000#->addMessageToQueues('inventory.reserv...', '{"skus":["Macboo...', array('inventory.reserv...')) called at [vendor/magento/module-mysql-mq/Model/Driver/Exchange.php:73]
#11 Magento\MysqlMq\Model\Driver\Exchange#00000000000014120000000000000000#->enqueue('inventory.reserv...', &Magento\Framework\MessageQueue\Envelope#00000000000013e90000000000000000#) called at [vendor/magento/framework-message-queue/Publisher.php:95]
#12 Magento\Framework\MessageQueue\Publisher#0000000000000fb50000000000000000#->publish('inventory.reserv...', '{"skus":["Macboo...') called at [vendor/magento/framework-message-queue/PublisherPool.php:89]
#13 Magento\Framework\MessageQueue\PublisherPool#0000000000000fb40000000000000000#->publish('inventory.reserv...', &Magento\InventoryIndexer\Model\Queue\ReservationData#00000000000013e30000000000000000#) called at [vendor/magento/module-inventory-indexer/Plugin/InventorySales/EnqueueAfterPlaceReservationsForSalesEvent.php:77]
#14 

...

   2023-05-25 15:04:45
    EXCEPTION
    PDOException: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`{magento cloud project id}`.`queue_message_status`, CONSTRAINT `QUEUE_MESSAGE_STATUS_MESSAGE_ID_QUEUE_MESSAGE_ID` FOREIGN KEY (`message_id`) REFERENCES `queue_message` (`id`) ON DELETE CASCADE) in /app/{magento cloud project id}/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:90
    Stack trace:
    #0 /app/{magento cloud project id}/vendor/magento/framework/DB/Statement/Pdo/Mysql.php(90): PDOStatement->execute(Array)
    #1 /app/{magento cloud project id}/vendor/magento/framework/DB/Statement/Pdo/Mysql.php(106): Magento\Framework\DB\Statement\Pdo\Mysql->Magento\Framework\DB\Statement\Pdo\{closure}()
    #2 /app/{magento cloud project id}/vendor/magento/framework/DB/Statement/Pdo/Mysql.php(91): Magento\Framework\DB\Statement\Pdo\Mysql->tryExecute(Object(Closure))
    #3 /app/{magento cloud project id}/vendor/magento/zend-db/library/Zend/Db/Statement.php(313): Magento\Framework\DB\Statement\Pdo\Mysql->_execute(Array)
    #4 /app/{magento cloud project id}/vendor/magento/zend-db/library/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
    #5 /app/{magento cloud project id}/vendor/magento/zend-db/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT  INTO `q...', Array)
    #6 /app/{magento cloud project id}/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(564): Zend_Db_Adapter_Pdo_Abstract->query('INSERT  INTO `q...', Array)
    #7 /app/{magento cloud project id}/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(634): Magento\Framework\DB\Adapter\Pdo\Mysql->_query('INSERT  INTO `q...', Array)
    #8 /app/{magento cloud project id}/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(2125): Magento\Framework\DB\Adapter\Pdo\Mysql->query('INSERT  INTO `q...', Array)
    #9 /app/{magento cloud project id}/vendor/magento/module-resource-connections/DB/Adapter/Pdo/MysqlProxy.php(609): Magento\Framework\DB\Adapter\Pdo\Mysql->insertArray('queue_message_s...', Array, Array, 0)
    #10 /app/{magento cloud project id}/vendor/magento/module-mysql-mq/Model/ResourceModel/Queue.php(98): Magento\ResourceConnections\DB\Adapter\Pdo\MysqlProxy->insertArray('queue_message_s...', Array, Array)
    #11 /app/{magento cloud project id}/vendor/magento/module-mysql-mq/Model/ResourceModel/Queue.php(72): Magento\MysqlMq\Model\ResourceModel\Queue->linkMessagesWithQueues(Array, Array)
    #12 /app/{magento cloud project id}/vendor/magento/module-mysql-mq/Model/QueueManagement.php(89): Magento\MysqlMq\Model\ResourceModel\Queue->linkQueues('0', Array)
    #13 /app/{magento cloud project id}/vendor/magento/module-mysql-mq/Model/Driver/Exchange.php(73): Magento\MysqlMq\Model\QueueManagement->addMessageToQueues('inventory.reser...', '{"skus":["Macbo...', Array)
    #14 /app/{magento cloud project id}/vendor/magento/framework-message-queue/Publisher.php(95): Magento\MysqlMq\Model\Driver\Exchange->enqueue('inventory.reser...', Object(Magento\Framework\MessageQueue\Envelope))
    #15 /app/{magento cloud project id}/vendor/magento/framework-message-queue/PublisherPool.php(89): Magento\Framework\MessageQueue\Publisher->publish('inventory.reser...', '{"skus":["Macbo...')
    #16 /app/{magento cloud project id}/vendor/magento/module-inventory-indexer/Plugin/InventorySales/EnqueueAfterPlaceReservationsForSalesEvent.php(77): Magento\Framework\MessageQueue\PublisherPool->publish('invent`

Release note

This part of code was changed in 2.4.6
\Magento\ResourceConnections\DB\Adapter\Pdo\MysqlProxy::selectConnection

image

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Issue: needs updateAdditional information is require, waiting for responseReported on 2.4.6Indicates original Magento version for the Issue report.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions