Skip to content

Mysql DeadLocks  #18

@Kos-M

Description

@Kos-M

Hey , i notice some deadlocks trigered by PoolService and PoolServer.
This happen when PoolServer._flushSharesToDb() run in same time with
PoolService._removeOldDbEntries() .

Mysql Details:

 LATEST DETECTED DEADLOCK
------------------------
<>
*** (1) TRANSACTION:
TRANSACTION <>, ACTIVE 0 sec fetching rows
mysql tables in use 2, locked 2
LOCK WAIT 5 lock struct(s), heap size 1184, 237 row lock(s), undo log entries 12
MySQL thread id <>, OS thread handle <>, query id <> 127.0.0.1 <SERVICE> Sending data
DELETE shares
            FROM shares
            LEFT JOIN block on shares.prev_block=block.id
            WHERE block.height < <>
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 3127 page no 3 n bits 400 index `PRIMARY` of table `pool`.`shares` trx table locks 2 total table locks 2  trx id <>lock_mode X waiting lock hold time 0 wait time before grant 0
*** (2) TRANSACTION:
TRANSACTION <>, ACTIVE 0 sec starting index read, thread declared inside InnoDB 4993
mysql tables in use 1, locked 1
4 lock struct(s), heap size 1184, 6 row lock(s), undo log entries 2
MySQL thread id 9, OS thread handle <>, query id <>127.0.0.1 <SERVER>update
INSERT INTO shares (user, device, prev_block, count, difficulty)
            VALUES (<>), (<>), (<>), (<>), (<>), (<>), (<>) ON DUPLICATE KEY UPDATE count=count+values(count), difficulty=difficulty+values(difficulty)
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 3127 page no 3 n bits 400 index `PRIMARY` of table `pool`.`shares` trx table locks 1 total table locks 2  trx id <> lock_mode X locks rec but not gap lock hold time 0 wait time before grant 0
*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 3127 page no 3 n bits 400 index `PRIMARY` of table `pool`.`shares` trx table locks 1 total table locks 2  trx id <>lock_mode X locks rec but not gap waiting lock hold time 0 wait time before grant 0
*** WE ROLL BACK TRANSACTION (2)

Are conflict transactions re executed ? Or missing value data there ?
Any way to avoid deadlocks or at least workaround when this happening ?
P.S i removed some sensitive data where you see <>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions