I've been developing a fairly large ERP suite in Jade for almost 15 years and never had to bother with a locking strategy. I know most of you are thinking... "he's crazy". We run a singleUser app server (no Jade RAP) and funnel our core (contentious) transacations through a single process. With hardware and Jade improvements this strategy has just continued to work really really well.
Anyway, I now have a situation where I'm going to encounter lock exceptions and need to handle it. I feel like a bright eyed newbie again.
I'm not sure how this situation gave me a lock in the first place, and I I'm not sure which simple strategy I should to implement to avoid it.
Here's a ficticious scenario:
Library.allBooksByISBN
Book.myLibrary
All book objects already exist.
At a key time in the night there is a 2 hour window when one process is performing quite a few:
if library.allBooksByISBN.getAtKey (987654) then
At the same time another process is updating book isbn properties.
beginTransaction
book.setISBN(123456);
commitTransaction
About every 10 minutes I might get 40-50 book isbn look-ups, with approx 5 occurring per second.
The book isbn update transaction is occurring no more frequently than once every 5 seconds.
Given the simplicity of these 2 systems I would have thought I'd NEVER get a lock exception. I always assumed Jade performed a very basic lock acquire, timeout, retry and that under these very lite conditions the locks would always work them selves out.
Not the case, my book isbn update process got a lock exception last night and the culprit process was the book isbn look-up.
So is the best approach a simple lock exception handler right before my book.setISBN(123456), that simply performs a series of tryLock(...) attempts for a couple of seconds and hopefully (surely almost guaranteed?) acquires the lock, otherwise Ex_Pass_Back?