Yii Framework Forum: Automatic InnoDB deadlocks retry - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Automatic InnoDB deadlocks retry (proposition for adapter modification)

#1 User is offline   Ziggi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 166
  • Joined: 14-August 12

Posted 04 December 2017 - 09:55 AM

Hi

As application grows and traffic scales up we observe some increase in InnoDB deadlocks rate like this:

Database Exception – yii\db\Exception
SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction
The SQL being executed was: INSERT INTO `token` (`type`, `user_id`, `created_at`, `code`) VALUES (0, 23976, 1512392365, 'IDGDVci8FiZC_2S1g6Y-Vuk4WLSTVG4t')

Error Info: Array
(
    [0] => 40001
    [1] => 1213
    [2] => Deadlock found when trying to get lock; try restarting transaction
)

↵
Caused by: PDOException
SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction

in /home/****/vendor/yiisoft/yii2/db/Command.php at line 994



As you see - some of them are observed withing third-party extensions what effectively blocks simple resolution.

I propose to enhance PDO Adapter so it could handle deadlocks gently in a similar manner like here:

https://www.npmjs.co...eadlock-retries

You may see this in Magento as well:

https://github.com/A...ple/Aoe_DbRetry

How do you see this?
@Samdark, @Cebe, @Paul Klimov?
0

#2 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,193
  • Joined: 17-January 09
  • Location:Russia

Posted 06 December 2017 - 05:31 AM

Sounds OK. Do you want to propose it via GitHub pull request?
Yii 2.0 Development Cookbook

Enjoying Yii? Star us at github

Support me so I can work more on Yii: https://www.patreon.com/samdark
0

#3 User is offline   Ziggi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 166
  • Joined: 14-August 12

Posted 06 December 2017 - 05:36 AM

View Postsamdark, on 06 December 2017 - 05:31 AM, said:

Sounds OK. Do you want to propose it via GitHub pull request?


I could work on it on Christmas. Indeed - I could submit my result via pull request - why not? I will be in touch then!

Thank you, Alexandr.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users