Sample Header Ad - 728x90

Mysql locking - How to acquire a lock in the DB for each userId

0 votes
2 answers
192 views
Hi I have a J2EE Server(clustered) that executes requests from multiple users. I would like that each request of a given user will be handled like so: { acquireLockForUser(userId); // i.e. insert a lock row for a dedicated table doSomeStuffInDbForUser(user); releaseLock(userId); // i.e. delete a lock row from the dedicated table } This will make sure that each user request will be handled by a single thread of my servers. Whats the way to achieve that? (Is it possible to insert into a table 'userLock' by id and lock it? how to insert\fetch from this "lock" table?)
Asked by Urbanleg (375 rep)
Mar 30, 2016, 10:01 AM
Last activity: Jun 21, 2025, 04:09 AM