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

locking and owner

 
Mark Linese
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understood that with an owner a record is not avaiable for booking. Are you checking for the record validity (non-deleted / non-owner) after a wait inside lock method ? I have read that with one just file it�s not necessar to take care of this stuff and As I followed metadata approach I wouldn�t like to check the value of a specific field value, having it hard coded.

Thanks,
Mark Linese
 
Ales Moukhine
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mark Linese:
Are you checking for the record validity (non-deleted / non-owner) after a wait inside lock method ?


Hi Mark,
I don't think, that checking for the record validity inside lock method is a good idea. In my implementation i separate locking/unlocking code from implementation of the DB (my lockManager don't know anything about what it locks).
I check delete-validity of the record in read method, wich i call after lock.
my busines.book() :


I'm still in progress with scjd, so I don't know exactly is it good for Sun

Regards
Ales'
 
Daniel Bryant
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I agree with Ales - checking if the record is not owned would not be a good thing to do inside you lock method (it would be much better to completely seperate you file access and logical record locking into two seperate classes.)

However, (and it's a big however ) I would highly recommend checking if a record has been deleted between waiting for a lock and acquiring it. Ales - I think I see what you are doing, but would your system be able to handle the following situation?

1. Client A Locks Record 1.
2. Client B attempts to lock Record 1 - waiting
3. Client C attempts to lock Record 1 - waiting
4. Client A deletes Record 1
5. Client A unlocks Record 1 - notifyAll()
Now if you don't check if the record is deleted in your locking code how do client B and C deal with this? do they lock a non-existant record (and does this make sense-could this impact another thread creating a new record), or does only one client recieve notification and the other thread waits indefinitely?

This is quite a tricky problem and I only mention this as it's a problem I came up against (and several posts believe that not handling this problem could be the cause of the infamous 44/80 score for locking)

Best wishes,

Daniel
 
Ales Moukhine
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Daniel Bryant:

1. Client A Locks Record 1.
2. Client B attempts to lock Record 1 - waiting
3. Client C attempts to lock Record 1 - waiting
4. Client A deletes Record 1
5. Client A unlocks Record 1 - notifyAll()
Now if you don't check if the record is deleted in your locking code how do client B and C deal with this? do they lock a non-existant record (and does this make sense-could this impact another thread creating a new record), or does only one client recieve notification and the other thread waits indefinitely?


Hi Daniel,
Thank you for analyzing my piece of code
In my code, after lock() method folow method read(), wich throw RecordNotFoundException if record was deleted.
So after point 5, for example:
6. Client B Locks Record 1
7. method read() throw RecordNotFoundException for Client B
8. Client B unlock Record 1 and notifyAll()

I don't think that locking code must knows what it locks exactly, we create lock for some number, but we don't know that this is room record, and it can be in delete/undelete state.

Can you write links to posts you found?

Regards
Ales'

PS. Sorry for not answering so long, I have a little vacation
[ August 16, 2006: Message edited by: Ales Moukhine ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic