Maybe this one can help you out.

I made this years ago but it still helps me out once in a while. It does practically the same as the code Dennis has just contributed but it will suggest the right master/alias during the current save process in order for not having a lock timeout. You can hook it into your current error object and have it debug the master/alias when the timeout error occurs. An example for that is shown in the link.

You can also just call the report method just before your saverecord command or Request_save message is send. Just send
Send DoTrackLockError
It will give you a master/alias problem report.