Magento2Msp icon indicating copy to clipboard operation
Magento2Msp copied to clipboard

[DCW-383-49061] Unique constraint violation found

Open nocturnalfrog opened this issue 7 years ago • 8 comments

The /multisafepay/connect/success?transactionid=xxxxxxxxx and /multisafepay/connect/notification/?transactionid=xxxxxxxx&timestamp=yyyyyy URLs sometimes cause a "Unique constraint violation found" exception to be thrown.

The affected orders appear to be marked as payed, but the error does cause a severe error report in the frontend which freaks out the customers.

These errors occur on almost all out Magento 2 instances that use this module.

Trace:

#1 Magento\Framework\Model\AbstractModel->save() called at [vendor/multisafepay/magento2msp/Model/Connect.php:1342] 
#2 MultiSafepay\Connect\Model\Connect->_registerPaymentCapture() called at [vendor/multisafepay/magento2msp/Model/Connect.php:1213] 
#3 MultiSafepay\Connect\Model\Connect->notification() called at [vendor/multisafepay/magento2msp/Controller/Connect/Success.php:107] 
#4 MultiSafepay\Connect\Controller\Connect\Success->execute() called at [vendor/magento/framework/App/Action/Action.php:107] 
#5 Magento\Framework\App\Action\Action->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58] 
#6 MultiSafepay\Connect\Controller\Connect\Success\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] 
#7 MultiSafepay\Connect\Controller\Connect\Success\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/anowave/ec/Plugin/App/Action/Context.php:148] 
#8 Anowave\Ec\Plugin\App\Action\Context->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135] 
#9 MultiSafepay\Connect\Controller\Connect\Success\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#10 MultiSafepay\Connect\Controller\Connect\Success\Interceptor->___callPlugins() called at [generated/code/MultiSafepay/Connect/Controller/Connect/Success/Interceptor.php:26] 
#11 MultiSafepay\Connect\Controller\Connect\Success\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:55] 
#12 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58] 
#13 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] 
#14 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php:94] 
#15 Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135] 
#16 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/mirasvit/module-cache-warmer/src/CacheWarmer/Plugin/Debug/OnHitPlugin.php:107] 
#17 Mirasvit\CacheWarmer\Plugin\Debug\OnHitPlugin->aroundAroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135] 
#18 Magento\PageCache\Model\App\FrontController\BuiltinPlugin\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] 
#19 Magento\PageCache\Model\App\FrontController\BuiltinPlugin\Interceptor->___callPlugins() called at [generated/code/Magento/PageCache/Model/App/FrontController/BuiltinPlugin/Interceptor.php:26] 
#20 Magento\PageCache\Model\App\FrontController\BuiltinPlugin\Interceptor->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135] 
#21 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] 
#22 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26] 
#23 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:136] 
#24 Magento\Framework\App\Http->launch() called at [vendor/magento/framework/App/Bootstrap.php:257] 
#25 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:37] ```

nocturnalfrog avatar Jun 20 '19 12:06 nocturnalfrog

@nocturnalfrog

Thank you for reporting this issue. As of now. We cannot reproduce this issue. That is why we need the following information:

  • When did the issue first occur;
  • Which Magento 2 version you are using;
  • Which Multisafepay version you are using;

mikededecker1 avatar Jun 20 '19 14:06 mikededecker1

  • When did the issue first occur; 25 of May (but could be earlier)
  • Which Magento 2 version you are using; 2.2.8
  • Which Multisafepay version you are using; 1.6.3

Extra info: Our customer noticed that they receive the order confirmation emails of the affected orders twice.

nocturnalfrog avatar Jun 20 '19 15:06 nocturnalfrog

Because this issue requires a more in depth look, I am asking from you the following.

Can you send an email to [email protected] with the following details

  • [ ] The Exception.log file.
  • [ ] An staging environment identical to the live environment.

I Hope to hear from you futher by mail.

mikededecker1 avatar Jun 24 '19 08:06 mikededecker1

Hi @Mike-MultiSafepay

I'm facing the same issue. This seems to be related to a multi-server setup for Magento 2. For example, in Controller/Connect/Notification.php on line 116, a self-created lock mechanism is used to lock a transaction. This lock process, as defined in Helper/Data.php creates a temporary file, which is places on disk. To check if a process is locked, the code checks if the tmp file is present. If on the first webserver the tmp file is created, and the postback is fired to the second webserver at the same time (during the time the lock file is present), the both processes are trying to create a new transaction for the payment, which results in a unique constraint violation.

The locking process used is anything but safe, and I think database row locking should be used instead, to secure the data integrity.

peterkoppenaal avatar Oct 21 '19 11:10 peterkoppenaal

Hi @peterkoppenaal We are currently looking into your findings and will include your findings into our test cases. We will give you more information once more information has been acquired.

mikededecker1 avatar Oct 22 '19 11:10 mikededecker1

Hello @Mike-MultiSafepay

Any update on this issue?

aerofury avatar Mar 13 '20 09:03 aerofury

Hi @Jens-Bourgeois ,

Because we have only had 3 cases so far where this issue has happened, it is hard for us to come up with good solutions and test them in such a way that will guarantee that it will work.

Therefore we would like to ask you the following information:

  • Do you also use a multiserver setup?
  • Can you tell us how often and when this issue has occurred?

A few months ago we have also had e-mail contact about this issue. We have asked you if it was possible to send us the debug logs if the issue happened again, so we have multiple cases to compare it to. It would be of much help of you could send this information to [email protected] Is this something that is possible for you?

vinodsowdagar avatar Mar 16 '20 09:03 vinodsowdagar

Hi @nocturnalfrog , @peterkoppenaal , @Jens-Bourgeois ,

Thank you for reporting this.

Unfortunately, this plugin is deprecated and we are not providing support for it anymore. Please upgrade to our New Magento 2 plugin..

This issue has not occurred in the new plugin and the new plugin also has tons of other improvements. I am closing this issue for now. If you have any more comments or questions, feel free to create a new issue in the new plugin repo.

vinodsowdagar avatar Aug 06 '21 13:08 vinodsowdagar