• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

db: concurrent reads to single record?

 
Brandon Hill
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • 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
 
Emerson Dunne
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
I read the specs again. This question isn't needed. Sorry about this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic