"tallpsmith" wrote :
| If we pretent do be a DB for just a moment, doesn't SERIALIZABLE dictate
that no other connection can create a new row in a table while a SERIALIZABLE
transaction is in progress?
|
DBs don't need to acquire table locks in all situations, e.g. UPDATEs and READs
only acquire row locks, whereas INSERTS, DELETEs and queries need to acquire
table locks. Well, I should say this depends on the implementation and of
course only applies to pessimistic locking.
So the answer to your question would be 'no', because another TX can insert new
rows. However, if the current TX tries to do (e.g.) a query, then it needs to
acquire the table lock held by the other TX, and will block until released
(avoiding phantom reads).
anonymous wrote :
| Is there anyway I can implement the sort of behaviour I need? How can I
prevent 2 threads from even looking at the state of a Node in the cache while
some other thread has a lock on that Node.
|
To do that you have to create the node first. Because you cannot lock on a node
that doesn't exist. If you want to do a putIfExists(), then I suggest you
create a top node /a, and create all subnodes under /a. When you have
SERIALIZABLE and navigate down /a, all other TXs will be locked out until you
commit.
anonymous wrote :
| What about if I synchronized(..) on the actual Node before inspecting?
Could I:
|
| Object node = cache.get("/SecurityInfo/" +myId);
| synchronized(node) {
| -- read value of node
| --- do DB Lookup as necessary
| }
|
| If another Thread came along, I would hope it would block. Given that
there could me many many many 'myId's', I'd need to evict them after a while,
but long enough such that the get(..) call returned the exact same object for
multiple threads for the sync call to work.
| .
Very bad. Better is to make sure /SecurityInfo *always* exists (set eviction
policy to *not* remove this one node), then access its subnodes with
SERIALIZABLE. Only 1 TX will be able to proceed past the /SecurityInfo 'gate'
at any time.
This is bad for concurrency though...
Hmm, have you looked at CacheLoaders, e.g. JDBCCacheLoader ? This does exactly
what you want (if I understand your reqs correctly): whenever a node is not in
memory, the CacheLoader will load it from an external store, e.g. a DB. Load
and store is synchronized.
Bela
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3854975#3854975
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3854975
-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development