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

Popular posts from this blog

c++ - Linked List error when inserting for the last time -

java - activate/deactivate sonar maven plugin by profile? -

java - What is the difference between String. and String.this. ? -