3 Replies Latest reply on Nov 4, 2005 2:06 PM by manik

    Locks not working in networked TreeCaches?

    pr3ston

      We have two TreeCache caches that have CacheMode set to REPL_SYNC. When we aquire a lock(LOCK_TYPE_WRITE) on a TreeCache node in one cache, we are not prevented from GETting that node in the other cahce.

      When we run the same test with a single cache, the lock does prevent us from doing the GET on the locked node.

      This seems to only be a problem with replicating the locks since our other tests indicate that we are able to see changes made in one cache in the other cache.

      Can someone help? We have tried to use the locking API but it is not clear from the Javadoc on how to use it.

      Thanks,
      Preston

        • 1. Re: Locks not working in networked TreeCaches?
          manik

          Behaviour on a single cache is as expected. When you use this with 2 caches, locks on the remote cache are only acquired during the prepare phase of committing the transaction.

          • 2. Re: Locks not working in networked TreeCaches?
            pr3ston

            Hi Manik,

            So, from what you said it seems that if we start a transaction and modify 2 nodes, those nodes get locked across the cluster only during the commit phase of the transaction. Is this correct? Is there any way to lock a node on modification?

            Is there any other way to lock a node across the cluster and then release it? Do you have any recommendations on an open source transaction manager that we can use to achieve this?

            Thank you for your help.

            Regards,
            Preston

            • 3. Re: Locks not working in networked TreeCaches?
              manik

               

              "pr3ston" wrote:

              Is there any way to lock a node on modification?


              The short answer is no. It is upon replication that other caches in the cluster are considered in the tx.

              "pr3ston" wrote:

              Is there any other way to lock a node across the cluster and then release it? Do you have any recommendations on an open source transaction manager that we can use to achieve this?


              Unfortunately no. Distributed locks are created during the prepare phase and are released after commit or rollback, just like any distributed transaction manager would handle it. This is pretty much how distributed transactions work.

              With JBossCache 1.3 we will be releasing optimistic node locking (see [http://wiki.jboss.org/wiki/Wiki.jsp?page=OptimisticNodeLocking]) which may be able to help though. This is also available in 1.2.4 as alpha quality...

              "pr3ston" wrote:

              Thank you for your help.


              No probs!