magento2: SQL error with cron job messagequeue_clean_outdated_locks
The cron job messagequeue_clean_outdated_locks fails and results in an error. This causes all following cron tasks to become “Too late for the schedule” and stops execution of all crons. The “message” from the cron_schedule table says:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT queue_lock.* FROM queue_lock WHERE (created_at <= ‘2017-06-03 09:04:’ at line 1, query was: DELETE FROM (SELECT queue_lock.* FROM queue_lock WHERE (created_at <= ‘2017-06-03 09:04:48’))
I ran this query manually to double check and it indeed fails. Seems like this could/should be written without the sub select.
Preconditions
- Magento version 2.1.5
- PHP 5.6.30
- MySQL: Server version: 5.7.17-11 Percona Server
Steps to reproduce
- Unsure on steps. Just open the cron_schedule table and it’s there.
Expected result
- The cron job should complete successfully.
Actual result
- The cron job messagequeue_clean_outdated_locks fails and results in an error. This causes all following cron tasks to become “Too late for the schedule” and stops execution of all crons.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 8
- Comments: 15 (7 by maintainers)
Same the error in Magento EE: 2.1.6 and have a little worry as don’t have any action about changing status for this issue: BTW, My code for overriding:
And this error is found by the integration tests
How did it get into production?
Got the same issue on my side. The cron call the delete as following:
$this->getConnection()->delete($selectObject);But it should be$this->getConnection()->deleteFromSelect($selectObject, $this->getTable(self::QUEUE_LOCK_TABLE));vendor/magento/module-message-queue/Model/ResourceModel/Lock.phpEven if the select return nothing i have the error, so it’s not related to the select. The syntax of the delete is just wrong.