CobbLiu
CobbLiu

Reputation: 457

Can `GET_LOCK` blocks infinite seconds in MySQL

MySQL's GET_LOCK(str,timeout) function be used to implement application locks or to simulate record locks.
If I want to wait infinite seconds, How can I call GET_LOCK?
Does GET_LOCK('lock_name', -1) work?

Upvotes: 0

Views: 217

Answers (1)

bansi
bansi

Reputation: 57062

Yes with GET_LOCK('lock_name', -1) you can wait wait infinite seconds. This is not documented and was buggy. It is still not documented but as per bug reports this feature is fixed on version 5.5 and up.

Reference: GET_LOCK() timeout behaves differently on differing platforms

PS: Use this feature carefully. As it is not documented the behaviour may change in a future version.

Upvotes: 1

Related Questions