jdbc - Mysql InnoDB locking for atomic read -


i have website, has method (in backing bean) several read-requests (to check e.g. users' rights) , insert data.

the prodecure looks this:

1.) select * userlocks (table logs users exclusively working on topic, avoid redundancy). checks if there no lock (user working) topic. 2.) select * ... (some other selects further checking) 3.) insert userlocks (curuser, timeout) values (...) (if ok, create new lock current user topic) 

the problem facing is: between first select , insert many other users can request same website manipulates data of table userlocks. seems not thread-safe.

is there solution problem? need used tables locked during procedure other users. (the other request should wait until lock released, dont take more half second...)

(i use innodb)

i suggest need research sql transactions little , row , table locks innodb. article helped me https://blogs.oracle.com/mysqlinnodb/entry/introduction_to_transaction_locks_in


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -