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

some ideas about detecting the lock timeouts

 
Olena Golub
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
I have some ideas about detecting the locks timeouts and preventing the dead locks.

I will define the Lock class that contains the long Lock-Cookie and the expiration time.
After the lock method is called, the lock-cookie is generated. My lock-cookie should be long.
Instead of wraping the cookie to Long, i will wrap generated cookie
in one Lock-object. And in the lockedRecord Array I will save the record-number and this Lock-Object.
In Data I will define one private method:
detectDeadLocks()
This method checks the Lock-object in this array. And if the Lock-Object has an expired time, than deletes the
paar with the Lock-Object and the record number from the lockedRecord array. And notify to all waiting threads.
This will be called in lock-Method:




One example:
the clientA called the lock-Method with the recNo1. After the lock-Method was called, the clientA crashed.
In 15 minutes the clientB want to lock the recNo1. ClientB calles the lock-Method but this record is still in lockedRecords.
The method detectDeadLocks is called. The method check the expiration time of this entry in the lockedRecord.
This time is more than 10 minutes and the recNo1 with lock cookie will be delete from the array.
And all waiting threads will be notified.
The clientB can now lock the recNo1.

How do you think about it?
I will make the expiration time about 10 minutes.
If the client puts the lock on the record. It can be locked this 10 minutes. If this will be locked
more than this time, the lock will be released.
How do you think is this time (10 minutes) enough?
Thanks a lot for your comment and ideas!

Olena
[ April 17, 2005: Message edited by: Olena Golub ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic