• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

record locking vs table locking

 
vin miller
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After reading many opinions on locking, no one has addressed the potential for the record number to change while waiting or holding the lock for it. For example, you are waiting to lock record 5. The thread that is running deletes record 4. Now your thread is notified and locks record 5, although the record that needed to be locked is now record 4 because of the delete. This can also happen in between read and update, which would cause the wrong record to be updated.
I tried to think of ways to prevent adding and deleting records while threads are waiting to lock for updates, but that doesn't seem practical. I thought of including a lock field in the db, but I don't think that's a good idea. The only other thing I can think of is to lock the whole table, which doesn't sound that great either.
Any ideas? Am I thinking too much into this?
 
Adrian Yan
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are reading too much into the thing. In the requirement, I don't see any mention of such problem, therefore, I'm not even concerning myself with it.
 
Jeff Young
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think this is a problem, since delete() doesn't actually remove the record, it just sets the record's attribute to DELETED_RECORD, so the record numbers will not change.
Jeff
 
vin miller
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I overlooked that. This is good to know, however writeRecord will change record numbers depending on the current location in the db file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic