Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Database lock (-1)???

 
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...................
 
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.
 
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.
 
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
 
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
 
Ranch Hand
Posts: 854
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?
 
I AM MIGHTY! Especially when I hold this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic