The maximum time that you can specify as the WAIT time in SET LOCK MODE is 32,767 seconds. Review this statement, and make sure it specifies the duration in seconds that you intended. If so, either use a shorter duration, or (since 32,767 seconds is more than 9 hours) simply omit the duration to specify an indefinite wait.