locks
locks copied to clipboard
cancel lock? what's needed
How could we cancel/release a lock before the end of the transaction? Any idea how it could be implemented?
From an implementation point of view, it would be pretty straightforward. One would have to think through whether it could cause problems with the algorithm, but I don't think it would.
where should you i look to implement it?
Well, locks_server has a function remove_agent(), which among other things calls remove_agent_from_lock(). This could be a starting point for an unlock operation.
In the locks_agent module, there is a remove_locks() function that can serve as inspiration. Also, you should look at the lock request to figure out what checks to run afterwards.
A problem might be the indirect messages. The agents directly involved in a lock will get notified, and the agent performing the unlock will remove its own references to it; it won't get a new message from the locks_server, of course. However, other agents that have received info via locks_agent:send_indirects() should probably receive some counter-info. A possible way to solve that might be for the recipient of an indirect lock info to start a monitor on it. This would be convenient, but most likely expensive. Cheaper perhaps for the agent who has sent indirect messages to remember the {OID, ReceivingAgent} pair for each message, but a complication is that this agent, after removing itself, will not receive the updated lock info.
ok i will have a look on it thanks for the explanation :)