• 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
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

How to handle this situation

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers
How should we handle the following condition:
Suppose a client calls lock(5) and then he calls lock(-1) without unlocking the previous rec 5.
a. Should the lock manager wait for a call of unlock(-5)
b. should the lock managet smart enough to give whole db lock as it knows the rec 5 is locked by the same client (subject to condition that all the other records are free)
I know some people argue that lock(-1) is for shutdown so this will never happen but i still believe that db lock can also be taken by clients as the application grows

Amit
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In what world will a client have to lock all the records? I would not worry about it for this assignment.
Mark
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


a. Should the lock manager wait for a call of unlock(-5)


This is a typo, right? You meant to say "Should the lock manager wait for a call of unlock(5)"?
Eugene.
 
Amit Kr Kumar
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Eugene, you are right
I mean unlock(5)
Amit
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


In what world will a client have to lock all the records?


IT world. Imagine you must add a record to a db based on the values of the last record stored. Imagine there is a field which contains a date value, so that you can compute which is the last stored record. So, you read and lock this last record, compute new values and add a new record. Let's suppose there is another application that is constantly modifying the date field of stored records and adding new records. How do you prevent this second application from corrupting your data? The only way is blocking the database (the table, at least). This block must prevent record modification, deletion and addition.
Amit, I treat differently database locks from record locks. A client can get a database lock if all the locked records in the database are his. After that, to unlock all the records the client must unlock the database and still unlock the individual records previously locked.
After getting a database lock no other client can add, delete or modify records.
However, after seeing a lot of posts I don't think this is required in this assignment. I wish I had realized that before implementing it.
 
I think she's lovely. It's this tiny ad that called her crazy:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic