to implement the pessimistic locking how to identify/know the data base table is locked or not?
Discussion posts and replies are publicly visible
You add a boolean or equivalent "locked" column to the database table that stores your record, or that is linked in some way to your record. You can also include a timestamp and user identification, but those aren't strictly required for it to work.
When a user attempts to start an action that could edit the record, you first query the lock. If it's set to true, you inform the user that you're so sorry they're not allowed to use it now. If it is set to false, you let the user continue their action, and the very first thing you do is set the locked column to true.
The very last thing your process does after all work on whatever action is complete is to set the lock back to false.
On the surface it's very easy. The difficult part is robustly handling all the various different forms of edge cases, such as abandoned processes not permanently locking all users out of a particular record, and other extraneous bits you have to account for when making your solution. But a rudimentary system to get you going isn't much beyond what I described above.
Thank you for advice
Can you please share what you have implemented for locking?