A high-performance application that has producers and consumers
of some resource, such as a queue of messages, needs an efficient
way to notify the consumers when the producer has inserted into
the queue. Polling the queue for changes is not a good option.
MySQL's GET_LOCK()
and RELEASE_LOCK()
functions can provide both mutual exclusivity and notifications.
This post was prompted by a message to the MySQL general emailing list some time ago, but I'm finally getting around to actually testing the theoretical solution I mentioned then. I can never just think my way through anything that involves locking and waiting... I have to test it.