How to detect deadlocks in Mysql / innodb?
Solution 1
http://dev.mysql.com/doc/refman/5.0/en/innodb-error-codes.html
1213 (ER_LOCK_DEADLOCK)
Transaction deadlock. You should rerun the transaction.
Solution 2
"SHOW ENGINE INNODB STATUS" from the MySQL Command line client (not a query browser) will give you info on deadlocks.
Deadlocks can also be caused by uncommitted transactions (usually program bugs) and the person who is running the uncommitted transaction will not see the problem as they will be working fine (through their data will not be committed).
Solution 3
Try MaatKit. It has a deadlock logger.
Solution 4
Try using MONyog. Enable MONyog's "Deadlock Monitoring" option to trace the deadlocks reported by INNODB STATUS. MONyog will send an alert to the user when a new deadlock occur.
Solution 5
If you are on a mac:
$ brew install percona-toolkit
$ pt-deadlock-logger -uroot --ask-pass localhost
kalculated
Updated on March 29, 2020Comments
-
kalculated about 4 years
I am trying to allow a user to select an image from gallery, then pass the image to the next screen as a parameter where they can finish their post (Similar to instagram create flow).
Using expo image picker, the button can be clicked which opens the gallery, and allows the user to select an image, and the gallery closes. This is done using this code:
async openImagePickerAsync() { let permissionResult = await ImagePicker.requestCameraRollPermissionsAsync(); if (permissionResult.granted === false) { alert("Permission to access camera roll is required!"); return; } let pickerResult = await ImagePicker.launchImageLibraryAsync() console.log(pickerResult.uri) if (pickerResult.cancelled === true) { return; } this.setPicked(pickerResult); };
The console logs the uri, everything is great. The picture is selected. The problem begins in the this.setPicked function call, where I am simply confirming a picture was selected and setting the state:
setPicked = (pickerResult) => { console.log("called setPicked") if (pickerResult !== null) { console.log("pickerResult not null") this.setState({ image: pickerResult.uri }).bind(this) console.log(pickerResult.uri) console.log(this.state.image) } else { console.log("pickerResult is null") return; } }
None of the print statements are printing, and I get this warning in the console:
[Unhandled promise rejection: TypeError: undefined is not an object (evaluating 'this.setPicked')]
Any idea what is going on? Thanks
-
Admin about 15 yearsThank you! That's what I was looking for.
-
Mei over 12 yearsMaatkit has been absorbed into the Percona Toolkit recently. The tool is called pt-deadlock-logger and was formerly mk-deadlock-logger.
-
Farid Movsumov about 8 years@S.Lott link is broken
-
OZZIE over 6 years@S.Lott google led me here.... kind of weird place to say such things ^^ when this is a place to gather such information
-
OZZIE over 5 yearsthere is a lot of output.. can I grep for something to detect it?
-
Guruparan Giritharan over 3 yearsWell you need to bind this or use an arrow function to get access to the context, refer this freecodecamp.org/news/…