Limited time wait

You can ask the database server to set an upper limit on a wait with the following statement:
SET LOCK MODE TO WAIT 17

This statement places an upper limit of 17 seconds on the length of any wait. If a lock is not removed in that time, the error code is returned.