Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Deadlock - if client dies holding a lockRecord()

 
Diarmuid McDonald
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Im in the middle of developing the project and have a problem regarding the lockRecord().

If multiple clients are connected to my RMI Server and two or more of them try to achieve a lock on a Record. The first thread will get the lock and the other(s) will wait(). If this client dies before the unlock is called, All other clients waiting for a lock on the record will wait forever.

Does anyone have any ideas or suggestions to overcome this problem.
 
Frans Janssen
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Diamuid,

This subject is discussed often here. You may find some threads about the subject using the search function on this forum ("Unreferenced" might be a nice keyword to start searching with).

I myself used a Timer to discard locks held by clients that showed no activity for some time. This also provided me with a (dirty) way out of deadlock situations.
Many people implement the Unreferenced interface, which will provide you with notifications when clients disconnect (although usually not immediately).

It seems though that many people have passed with excellent grades by not handling the situation at all. Stating that it is beyond the scope of the assignment in your choices.txt is apparently completely acceptable.

Frans.
 
Ken Kirin
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

For me I created a timer for each record everytime the lockRecord method is called. If that user dies before finishing an operation, the timer expires and I removed the lockcookie value from the lock object for that record. If this wouldn't happen I removed such lockcookie value in unlock method instead.

---------------
Ken Kirin
SCJP
SCWCD
SCJD ( B&S waiting for result..)
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Diamuid,

I did not handle this situation, citing in my choices.txt that I felt it was outside the scope of this assignment. I have already submitted my assignment, and when my results come in I'll make sure to let everyone know whether or not this is acceptable to Sun.
 
Vengan Krish
Ranch Hand
Posts: 32
 
Vengan Krish
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops messed up with the URL. Here you go -

http://www.coderanch.com/t/186632/java-developer-SCJD/certification/Unreferenced
 
Diarmuid McDonald
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replys

Paul I would be greatful if you would let know how you got on, as i dont want to spend time implementing and testing this problem if there is no need to.

Ken, if the a timer value is used, How did you determine what timeout value to use. Although performance is not a major issue of the project, wouldnt this impact the lockRecord alot, due to searching each record to see if the time was exceeded.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic