Obviously. I don't think anyone has proposed using Unreferenced for anything other than client crash cleanup. There is no requirement or provision in the FBN project for a transaction timeout - you would have to amend the API.Originally posted by Gennady Shapiro:
1. There is a thing to remember : client crash timeout and transaction timeout are two different things.
Your description of optimistic locking is inaccurate - what you are describing is still pessimistic locking, albeit for a brief period of time, and no locking otherwise. But that's not the point. The Unreferenced option is still as useful as ever in the second scenario (which I hope everyone is using, the first one is madness!) because, as stated, it is not a transaction timeout. It is simply a way to clean up locks if a client crashes (or its power goes or the network or...). And mishaps can happen while a client is holding a lock irrespective of how you organise your transactions.2. There are 2 types of transaction locking : pessimistic and optimistic. [...] The Unreference is useless [in optimistic locking]
Go tell that to Oracle, Microsoft and the other big guys out there. No database I know will aggressively time out transactions after a few seconds just like that. A couple of times I've been in a situation where it would take the (Oracle 8.1.5) database virtual eternity to clean up locks after a bad client crash. It's bad when that happens. But the alternative would make the database unworkable for applications that needed lengthy transactions.If the connection phisically breaks between lock() and unlock() you end up with a stale lock, thats true. But again, waiting for 10 minutes to unlock it -- is hardly a solution.
Here we agree. In fact I've stated repeatedly that I only did it because it was so laughably easy to do; decent and well-defined behaviour in case of client crashes at the cost of just three lines of code, features don't often come so cheap and it sure beats having no cleanup at all.I also think that stale lock removal is beyond the scope of this project and after loooong consideration I decided against doint it at all.(As long as I mention this in the documents)
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Originally posted by Peter den Haan:
Originally posted by Gennady Shapiro:
[b]1. There is a thing to remember : client crash timeout and transaction timeout are two different things.Obviously. I don't think anyone has proposed using Unreferenced for anything other than client crash cleanup. There is no requirement or provision in the FBN project for a transaction timeout - you would have to amend the API.
2. There are 2 types of transaction locking : pessimistic and optimistic. [...] The Unreference is useless [in optimistic locking]Your description of optimistic locking is inaccurate - what you are describing is still pessimistic locking, albeit for a brief period of time, and no locking otherwise. But that's not the point. The Unreferenced option is still as useful as ever in the second scenario (which I hope everyone is using, the first one is madness!) because, as stated, it is not a transaction timeout. It is simply a way to clean up locks if a client crashes (or its power goes or the network or...). And mishaps can happen while a client is holding a lock irrespective of how you organise your transactions.
If the connection phisically breaks between lock() and unlock() you end up with a stale lock, thats true. But again, waiting for 10 minutes to unlock it -- is hardly a solution.Go tell that to Oracle, Microsoft and the other big guys out there. No database I know will aggressively time out transactions after a few seconds just like that. A couple of times I've been in a situation where it would take the (Oracle 8.1.5) database virtual eternity to clean up locks after a bad client crash. It's bad when that happens. But the alternative would make the database unworkable for applications that needed lengthy transactions.
The locks are the most important. What I meant to say (but probably didn't) is that the intent is completely different from your short-lived transaction timeout idea. You appeared to be attacking Unreferenced for not being something it was never meant to be.Originally posted by Gennady Shapiro:
Well, what is client crash cleanup? If it's not the locks that the client imposed, what is?
That's correct (although it comes with more guarantees than finalize() does). And that's exactly how it's being used - as a last opportunity to clean up resources if everything else failed. In this particular application, the resources in question are record and database locks.I consider the Unreferenced a remote version of finalize. and finalize is designed to do "resource clean-ups" like files, network connections maintained by the session objects and should be explicitely closed.
It's a terminology issue. To avoid sidetracking the discussion I'll put my idea of optimistic locking in a footnote below.for the sake of this discussion [my description of optimistic model] is accurate enough
Ah. But this is not an application server. It's a database. We seem to agree that "real world" databases do not time out transactions, except (ahem) when a client crashes. And they take their own good time doing that. This is exactly the behaviour that the use of Unreferenced gives you. Not only that, it's exactly the kind of thing that Unreferenced is intended for. We don't seem to disagree that, if this is what you want to achieve, Unreferenced is the #1 way to do it.By saying that the Unreferenced should be used to clean up locks you effectively saying "if client crashes lets wait until his session times out then we'll clean up locks." I dont think it's a great idea. All app servers differentiate between object time to live and a transaction-time out.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
It's that last modification that changes the "optimistic lock" into "no lock". The term "lock", in the meaning I'm familiar with, means that no-one else can/should modify the record you've locked. A pessimistic locking scheme takes the pessimistic view that there will be attempts to modify the record and makes such modifications impossible. An optimistic locking scheme takes the optimistic view that there will not be any attempts to modify the record and is content to merely detect that the unthinkable has happened. The FBN application, as most implement it (the modified way you've outlined above), simply doesn't care if there were any modifications between the initial read and the seat allocation - there's no locking semantics at all. There's merely a business rule that after modification the #seats should be >= 0.Originally posted by Gennady Shapiro:
I think that the optmistic locking fits very well into FBN if you consider the Number od Available Seats the marker field.
The algorithm is this. [...] or even a better modification of that
4. is there still enough seats?
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd