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

Database lock (-1)???

 
Harry22
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Under what conditions would the whole database be locked? How would you un-locked it???
If records numbers are 1-24(ish), when would we be asking for lock with -1 as a parameter?

???
Thanks...................
 
Reshma Das
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
-1 lock is issued when server shutdown . it prevents other clients from obtaining locks for records. u dont have to unlock -1 lock.
 
sanjeev mehra
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
-1 will lock whole db.
do we need to lock all the records one by one (wait for record to unlock if it is already locked)? i mean, do we need to implement just above step (is it so simple) or i am missing something.
 
HanMing Low
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I think you need to lock one by one as you imagine.
If record 5 is already locked by some client, obtaining a lock of -1 does not seem to help.
You may have other implementation, feel free to comment.
Cheers.

Han Ming
 
Kuan Fan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
I don't think that lock-1 need to lock every record one by one.
I design three database status: LOCKED NORMAL LOCKING.
Just assign the status to Database. when there are any records are being locked, the lock-1 must wait. IF the database status is LOCKED or LOCKING, all the records lock action should be rejected.
hope helpful
stephen
 
Burk Hufnagel
Ranch Hand
Posts: 814
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I understand it, the lock() method is supposed to block until it can actually lock the requested record.
So if you start locking all the records because of a lock(-1) call then what happens to any remote clients that attempt to lock a record? Unless you throw an exception, they'll just sit there waiting for the record when it may be that the record will not be unlocked because the server is shutting down.
Seems to me that you'd want the lock() method to throw some kind of ServerShuttingDownException so the client can handle it as gracefully as possible. I'm not sure that throwing an exception is the "best" way to handle it, but I think it's better than allowing the client to sit and wait until the user gives up and shuts it down.
Comments, anyone?
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic