1 Reply Latest reply on May 31, 2005 10:44 AM by belaban

    Is the get/put atomic

    rajanik

      Hi,

      I had a question. As of now i am using the Jboss Cache in our bank application, which is a large scale application with lots of threads. I have registered the Tree Cahce as a Mbean and am accessing the Mbean to put and get data from the cache.

      I had the following Questions: Please pardon me if the questions are lame. :)

      1) I am not using Transactions and do not want to, but i have this line in my configuration file,

      org.jboss.cache.GenericTransactionManagerLookup

      Do you think i should comment it.

      2) I used Repeatable read as the isolation level initially, but evry now an then i get a lock time out exception from the Jboss Cache when trying to acquire a Write lock. It always complains that there is one Read Lock still not released. the application as i told is multithreaded application basically Session Beans.

      3) So i changed to Read Committed, and i still have the same issue. I am not sure whether there is a dead lock and the read or the write locks which some thread has is not getting released. I have increased the time out to 20 minutes, thinking that i will have give some time for the threads to gibe up the locks, but no luck.

      4) Hence i want to use "NONE" isolation level. The data that we are caching is baiscally data from the DB and cannot be altered or changed in the DB by the users. So to reduce time to access from the DB each time, we are using Jboss Cahe and i have an eviction policy which invalidates or evicts all the data in the cache which is say 15 minutes or older.

      So the question that i have is: are the put and get calls atomic?

      Thanks & hoping some one will help me :) Please let me know if you have more questions.

      Cheers
      Rajani

        • 1. Re: Is the get/put atomic
          belaban

           

          "rajanik" wrote:
          Hi,

          I had a question. As of now i am using the Jboss Cache in our bank application, which is a large scale application with lots of threads. I have registered the Tree Cahce as a Mbean and am accessing the Mbean to put and get data from the cache.

          I had the following Questions: Please pardon me if the questions are lame. :)

          1) I am not using Transactions and do not want to, but i have this line in my configuration file,

          <attribute name="TransactionManagerLookupClass">org.jboss.cache.GenericTransactionManagerLookup</attribute>

          Do you think i should comment it.


          Yes, you can comment it if you don't use transactions


          2) I used Repeatable read as the isolation level initially, but evry now an then i get a lock time out exception from the Jboss Cache when trying to acquire a Write lock. It always complains that there is one Read Lock still not released. the application as i told is multithreaded application basically Session Beans.


          Sounds like normal lock contention. Look at DeadlockTest for a simple deadlock, causing a TimeoutException.


          3) So i changed to Read Committed, and i still have the same issue. I am not sure whether there is a dead lock and the read or the write locks which some thread has is not getting released. I have increased the time out to 20 minutes, thinking that i will have give some time for the threads to gibe up the locks, but no luck.



          Increasing the timeout is always a bad thing, causing threads to hang on to their locks for longer, rather than throwing a TimeoutException.

          Note that if you don't use transactions, this means that you acquire a lock for each method, and release it after the method returned. Use the TreeCache.printLockInfo() to see the current locks.


          4) Hence i want to use "NONE" isolation level. The data that we are caching is baiscally data from the DB and cannot be altered or changed in the DB by the users. So to reduce time to access from the DB each time, we are using Jboss Cahe and i have an eviction policy which invalidates or evicts all the data in the cache which is say 15 minutes or older.


          NONE is only okay if you don't modify the cache.


          So the question that i have is: are the put and get calls atomic?


          Yes, they are, even without transactions being used. But you need an isolation level > READ_COMMITTED to prevent dirty reads and concurrent puts().