• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: who is responsible for lock

 
Jason Hocker
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 1.3.1 URLyBird. so DBMain has create(Strin[] data), and lock(int) and unlock(int). My thinking is that the server side should be responsible for the locks, and should within the create method call lock, do the create, and call unlock. But since lock and unlock are both exposed as public in this interface, should the client be responsible for the locks and unlocks? Does the database care who locked the files and only lets those clients do the unlock, or can any rogue client call unlock? What should be on the server to prevent this?
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jay,
You might be interested in reading the (very long) thread "Should lock methods be callable by the client". That may firm up your ideas about whether the client should be able to call lock() directly or not.
I am sure others here will explain why calling lock() from within create() (or any of the other public methods) is not a good idea.
Regards, Andrew
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jay
Originally posted by Jay Simpson:
My thinking is that the server side should be responsible for the locks, and should within the create method call lock, do the create, and call unlock.

I do not understand why you are calling lock in the create method. All create method does is to create a new record. Before creating a record, how are you going to lock? And on what are you planning to lock?

But since lock and unlock are both exposed as public in this interface, should the client be responsible for the locks and unlocks?

Well, if you have read the link Andrew has given(it must have took alteast 3-4 hrs, when I read it sometime back, it took almost 3hrs and I gave up without reading the last page) you would have a complete idea on what to do. Its upto you to allow clients to lock or unlock.
BTW, if you don't want clients to know about locking, then you are going with 3-tier design and Phil would be happy to see that What do you say Phil? (Now, Andrew gets mad on us as we are not sticking with 2-tier )

Does the database care who locked the files and only lets those clients do the unlock, or can any rogue client call unlock?

We should worry about that and should not allow to let other clients unlock other the locked client.

What should be on the server to prevent this?
[/qb]
A very robust and almost perfect locking mechanism.
[qb]

I am not sure if I answered your questions right. But from what I understood from your questions, I answered them accordingly.
Good Luck.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic