• Post Reply Bookmark Topic Watch Topic
  • New Topic

Optimistic record locking

Ihor Strutynskyj
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm thinking of implementing optimistic record locking for this assignment. The idea is simple. Keep the version number for each record (in the separate file - since it is not feasible to modify the db structure), and use it with each read/write.
(I execute booking logic on the RMI client).
For reading (atomized):
- read the record along with its version.
For writing (atomized):
- read the current record version
- compare current version with the version of client request and if they are the same write changes to the db
- otherwise notify client to reread the record and resubmit the request
- with each write increment the record version.
The booking transaction will consist of one method call modify() on the RMI server which will wrap the call to Data.modify() with the above described procedure. In the local mode actual Data.modify() will be used.
Advantages: clients that fail before the final write do not affect each other; no locking/timing is involved
Disadvantages: extra data file, possibility of loosing points for not following instructions and not implementing lock()/unlock() methods.
Any comments are welcome.
Regards, Ihor
vladimir levin
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would stick with the spec. They want you to
demonstrate that you can implement a write-lock. Straying
from the spec strikes me as the best way to fail an otherwise
straightforward certification.
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!