Synchronizing stored procedures in mysql -
i have 2 applications, both of them using same stored procedure in mysql. procedure synchronized, while 1 applications calls it, other 1 has wait.
is there way without altering codes of applications (that modifying stored procedure)?
thanks, krisy
you can absolutely within stored procedure without changing application code, bear in mind you're introducing locking issues , possibility of timeouts.
use get_lock() , release_lock() take care of synchronization. run get_lock perform synchronization @ start of stored procedure, , release_lock once you're done:
if (get_lock('lock_name_for_this_sp', 60))    .... body of sp    release_lock('lock_name_for_this_sp'); else    .... lock timed out end if   you'll need take care application timeouts longer lock timeout don't incur other problems.
Comments
Post a Comment