4 Replies Latest reply on Aug 31, 2005 12:47 AM by ruchiahuja10

    Cache Replication takes prior to transaction commit

    ruchiahuja10

      I have plugged in TreeCache in hibernate. Initially i was using jboss-cache-1.2.2 with hibernate 2.1.6. However due to a issue reported in the following link, i was asked to upgrade to hibernate 3.
      http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3885216#3885216

      Now i have upgraded to hibernate 3. I am observing that cache replication is taking place prior to transaction commit. This is how i tested this -

      server 1 server 2
      1. transaction begin 1.
      2. retrieve - cache miss 2.
      3. sleep 3. transaction begin, retrieve, transaction commit
      4. commit


      when i was using hibernate 2.1.6, i used to get cache miss in 3rd step on server 2.

      Now in hibernate 3, i get a cache hit in 3rd step on server 2.

        • 1. Re: Cache Replication takes prior to transaction commit
          ruchiahuja10

          In ReplicationInterceptor.invoke() the Transaction Manager = com.ibm.ws.Transaction.JTA.TranManagerSet@17adf499 and Transaction = com.ibm.ws.Transaction.JTA.TransactionImpl@18e834bf#tid=2

          In TreeCache.getLocalTransaction() the Transaction Manager = com.ibm.ws.Transaction.JTA.TranManagerSet@17adf499 and Transaction = null

          I am unable to understand why am I getting null transaction in TreeCache.getLocalTransaction().

          any idea???????

          • 2. Re: Cache Replication takes prior to transaction commit
            ruchiahuja10

            I just checked the hibernate 3 source. Transaction is suspended before invoking certain methods of jboss treecache. Thats why cache replication is taking prior to transaction commit.

            • 3. Re: Cache Replication takes prior to transaction commit
              xavierpayne2

              I might be missing something but isn't that the behavior that's desired if your cache is REPL_SYNC. This means that a commit should only be performed after all nodes confirm that they have the same data. If you want different behavior try setting your cache to REPL_ASYNC

              • 4. Re: Cache Replication takes prior to transaction commit
                ruchiahuja10

                Here are few lines from the treecache tutorial(http://docs.jboss.org/jbcache/current/TreeCache/html/) -

                When a change is made to the TreeCache, and that change is done in the context of a transaction, then we wait with replication until the TX commits successfully. All modifications are kept in a list associated with the transaction for the caller. When the TX commits, we replicate the changes. Otherwise, (on a rollback) we simply undo the changes and release the locks, resulting in no replication traffic. For example, if a caller makes 100 modifications and then rolls back the TX, we will not replicate anything, resulting in no network traffic


                It says that replication doesnt takes place after every change, rather the changes are replicated all together on transaction commit. I just want to ensure this statement still stands.