Closed ddosia closed 9 years ago
Could you try the PR above ( #20 )? I added a test case, which did fail before this fix.
It doesn't crash any more, but it hangs forever on both sides when I am trying to acquire write lock. My naive understanding of upgrade lock is like that: both acquires read lock, first tries to upgrade to write lock and this implies that it releases read lock and stands in the end of the queue, second does the same and should release read lock and step after first one. Maybe I misunderstand how lock upgrade works? Why then deadlock detection mechanism doesn't prevent me from this?
It's not a question of the deadlock resolution algorithm, but rather of the lock upgrade semantics. Specifically, the locks_server handles the trivial case of upgrade when there's one read lock, but when there are several read locks, it can't differentiate between agents that want nothing more than a read lock and agents that are holding a read lock but hoping to upgrade.
I'm at a Halloween party, so probably not sober enough to tackle the issue right now, nor would it likely be socially acceptable. ;-)
If contribs are offered, I'll gratefully review them. Otherwise, I'll take a look at this later.
Another problem is that the test case needs to verify that the two write lock requests reach different results (currently, they both time out, which is wrong).
I've pushed some fixes to the uw-lock_upgrade3 branch. They seem to fix the problem.
Could you try to verify at your end?
It works now, first actor obtains write lock immediately after second tries to acquire write lock. thanks!
Thanks! I've merged PR #20 into master.
I have two actors which works approximately in the same time. Each of them begins transaction. Each of them acquires
read
lock on the sameoid()
. Then first tries to upgrade read lock to write lock. Second does the same and application crashes immediately:Logs of the first actor:
Logs of the second actor:
I am new to locks so I am trying to learn how it works. In some sense I need lock upgrade functionality, that is why I was curious how it works. Maybe I miss something and what I did goes against very basics of what locks should do.