It might be paranoid but I wonder if using a lock would be a good thing for this proc. http://dev.mysql.com/doc/refman/5.1/en/miscellaneous-functions.html#function_get-lock