Deadlock in mysql

Tags: #<Tag:0x00007f1866116798>

I get this error in the application lock on my server:

Is this an implementation problem og the MySql adaptor or something deeper ? It happens a few time every day but not related to specific events.

MySql.Data.MySqlClient.MySqlException (0x80004005): Deadlock found when trying to get lock; try restarting transaction
at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
at Dapper.SqlMapper.ExecuteCommand(IDbConnection cnn, CommandDefinition& command, Action`2 paramReader)
at Dapper.SqlMapper.ExecuteImpl(IDbConnection cnn, CommandDefinition& command)
at Hangfire.MySql.MySqlDistributedLock.AcquireLock(String resource, TimeSpan timeout)
at Hangfire.MySql.MySqlDistributedLock.Acquire()
at Hangfire.MySql.ExpirationManager.<>c__DisplayClass6.b__0(MySqlConnection connection)

I have these details:
executing
INSERT INTO DistributedLock (Resource, CreatedAt) SELECT ‘locks:schedulepoller’, ‘2017-01-15 05:04:35.387605’ FROM dual WHERE NOT EXISTS ( SELECT * FROM DistributedLock WHERE Resource = ‘locks:schedulepoller’ AND CreatedAt > ‘2017-01-15 05:03:35.387605’)

executing
INSERT INTO DistributedLock (Resource, CreatedAt) SELECT ‘expirationmanager’, ‘2017-01-15 05:04:35.387605’ FROM dual WHERE NOT EXISTS ( SELECT * FROM DistributedLock WHERE Resource = ‘expirationmanager’ AND CreatedAt > ‘2017-01-15 05:04:05.387605’)

*** WE ROLL BACK TRANSACTION (2)

I have the same question。 any progress? thanks

Do we know what is the cause of it? How to fix it?