adyen-magento2
adyen-magento2 copied to clipboard
FIX: Prevent deadlock exception caused by concurrent execution of adyen_payment_process_notification and aggregate_sales_report_order_data
Issue
Issue
Occasionally, we encounter a deadlock exception when the aggregate_sales_report_order_data
cron job runs. This results in orders being left in an inconsistent state.
Cause
The adyen_payment_process_notification
and aggregate_sales_report_order_data
cron jobs can run concurrently and may attempt to access/modify the same sales_order_item
row, leading to a deadlock.
As the Adyen adyen_payment_process_notification
cron job does not have a proper rollback strategy (as requested here: https://github.com/Adyen/adyen-magento2/issues/1933), the affected order is left in an invalid state, such as missing the invoiced amounts.
Solution
To address this issue, we have made the adyen_payment_process_notification
cron job dependent on the completion of the aggregate_sales_report_order_data
job. This ensures that the adyen_payment_process_notification
job will not run until the aggregate_sales_report_order_data
job has completed.
Tested scenarios
- [x] General processing of Adyen notifications still works
- [x] The
adyen_payment_process_notification
is not executed while the cronjobaggregate_sales_report_order_data
runs.
Fixes #1933
Remark
I strongly believe that the WebhookProcessor
should still implement a proper rollback strategy in case of a failure are described with this comment: https://github.com/Adyen/adyen-magento2/issues/1933#issuecomment-1432738663
As you can see this specific issue can happen with any Magento instance that uses the Adyen Magento plugin and is not caused by other third-party extensions.