• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

db: concurrent reads to single record?

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DB question:
Do we have to allow for concurrent reads to a single record?
Meaning should we allow:
thread A reads record 1
// in the middle of a read vm switches threads
thread B reads record 1
This would be dangerous if thread B is writing to a record. This scenario would require an addition locking mechanism than the one provided.
Or
Should the second request to read the same record block until the first request is finished.
I think the project only requires that we have to allow for concurrent reads to the entire database but not a single record. In this case we would (using the specified lock and unlock)lock on a record for either reading or writing.
Brandon
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My instructions included the following:
"Note that the locking required is effectively a "write" lock only."
So, given these instructions I have not concerned myself with read locking.
 
Brandon Hill
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But if you don't lock a record on a read the following can happen:
Thread A reads record 1
// middle of read vm switches thread
Thread B writes to record 1
// vm switches thread
Thread A reads remaining part of record. Thread A's read now contains part of the old record 1 and part of the new record 1.
 
Brandon Hill
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I read the specs again. This question isn't needed. Sorry about this.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic