5 Replies Latest reply on Feb 26, 2008 2:36 PM by dh717

    Remove is not properly deleting child nodes when run in a tr

    dh717

      I have code that (within a single transaction) removes a node and then puts a new value into the cache that is a child of the removed node. After the transaction completes, the cache contains the new value AND the child nodes that should have been removed when the parent node was removed. If I execute the same code without a transaction, it works correctly, only the new value is present and all of the original children of the removed node are gone. The following code is a simple demonstration of the problem:


      public class RemoveNodeTxProblem {
      public static void main(String[] args) throws Exception {
      CacheFactory<String, Object> factory = DefaultCacheFactory.getInstance();

      Cache<String, Object> cache = factory.createCache(new XmlConfigurationParser().parseFile(args[0]), false);
      cache.create();
      cache.start();

      Fqn rootFqn = Fqn.fromString("/a/b");
      cache.put(rootFqn, "c", true);

      TransactionManager txMgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
      txMgr.begin();
      cache.removeNode(rootFqn);
      cache.put(rootFqn, "d", "Blah");
      txMgr.commit();

      System.out.println("c = " + cache.get(rootFqn, "c")); // c = true when tx is used, null when tx is not used
      System.out.println("d = " + cache.get(rootFqn, "d"));

      cache.stop();
      }
      }


      Is this a bug? If not, is there a way to get the non-transactional behavior (deleted children don't come back after a new child is added) in a transactional way? I'm running JBoss Cache 2.0.0 GA and JOTM 2.0.9 as my transaction manager.

        • 1. Re: Remove is not properly deleting child nodes when run in
          mircea.markus

          This looks a bug. Can you please post the cache config file?

          • 2. Re: Remove is not properly deleting child nodes when run in
            mircea.markus
            • 3. Re: Remove is not properly deleting child nodes when run in
              brian.stansberry

              Amazing. I hadn't seen this thread when I filed that bug. Total coincidence.

              • 4. Re: Remove is not properly deleting child nodes when run in
                dh717

                Here's the cache config file. Note that JotmTxMgrLookup is a custom TransactionManagerLookup implementation that creates a Jotm instance and returns a reference to its TransactionManager.


                <?xml version="1.0" encoding="UTF-8"?>

                <!-- ===================================================================== -->
                <!-- -->
                <!-- Sample TreeCache Service Configuration -->
                <!-- -->
                <!-- ===================================================================== -->






                <!-- ==================================================================== -->
                <!-- Defines TreeCache configuration -->
                <!-- ==================================================================== -->



                jboss:service=Naming
                jboss:service=TransactionManager

                <!--
                Configure the TransactionManager
                -->
                JotmTxMgrLookup

                <!--Optimistic-->

                <!--
                Isolation level : SERIALIZABLE
                REPEATABLE_READ (default)
                READ_COMMITTED
                READ_UNCOMMITTED
                NONE
                -->
                REPEATABLE_READ

                <!--
                Valid modes are LOCAL
                REPL_ASYNC
                REPL_SYNC
                INVALIDATION_ASYNC
                INVALIDATION_SYNC
                -->
                REPL_SYNC

                <!--
                Just used for async repl: use a replication queue
                -->
                false

                <!--
                Replication interval for replication queue (in ms)
                -->
                0

                <!--
                Max number of elements which trigger replication
                -->
                0

                <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
                cluster in order to find each other. This will be over-written in
                kernel service.
                -->
                TestCluster

                <!-- Specifies whether each interceptor should have an associated mbean registered.
                Interceptor mbeans are used to capture statistics and display them in JMX.
                This setting enables or disables all such interceptor mbeans.
                -->
                true

                <!-- JGroups protocol stack properties.
                -->


                <TCP start_port="8800"
                loopback="true"
                recv_buf_size="20000000"
                send_buf_size="640000"
                discard_incompatible_packets="true"
                max_bundle_size="64000"
                max_bundle_timeout="30"
                use_incoming_packet_handler="true"
                use_outgoing_packet_handler="false"
                down_thread="false" up_thread="false"
                enable_bundling="false"
                use_send_queues="false"
                sock_conn_timeout="300"
                skip_suspected_members="true"/>
                <TCPPING timeout="3000"
                initial_hosts="127.0.0.1[8800]"
                port_range="1"
                num_initial_members="2"/>
                <MERGE2 max_interval="100000"
                min_interval="20000"/>
                <FD_SOCK/>
                <FD timeout="10000"
                max_tries="5"
                shun="true"/>
                <VERIFY_SUSPECT timeout="1500" />
                <pbcast.NAKACK max_xmit_size="60000"
                use_mcast_xmit="false"
                gc_lag="0"
                retransmit_timeout="300,600,1200,2400,4800"
                discard_delivered_msgs="true"/>
                <pbcast.STABLE stability_delay="1000"
                desired_avg_gossip="50000"
                max_bytes="400000"/>
                <pbcast.GMS print_local_addr="true"
                join_timeout="3000"
                join_retry_timeout="2000"
                shun="false"
                view_bundling="true"/>
                <FRAG2 frag_size="60000" />
                <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
                <!-- <pbcast.STATE_TRANSFER/> -->
                <pbcast.FLUSH/>




                <!--
                Whether or not to fetch state on joining a cluster
                NOTE this used to be called FetchStateOnStartup and has been renamed to be more descriptive.
                -->
                true

                <!--
                The max amount of time (in milliseconds) we wait until the
                initial state (ie. the contents of the cache) are retrieved from
                existing members in a clustered environment
                -->
                15000

                <!--
                Number of milliseconds to wait until all responses for a
                synchronous call have been received.
                -->
                15000


                <!-- Max number of milliseconds to wait for a lock acquisition -->
                10000

                <!--
                Indicate whether to use region based marshalling or not. Set this to true if you are running under a scoped
                class loader, e.g., inside an application server. Default is "false".
                -->
                true



                • 5. Re: Remove is not properly deleting child nodes when run in
                  dh717

                  Trying again.

                  <server>
                   <classpath codebase="./lib/deploy" archives="jboss-cache.jar, jgroups.jar"/>
                   <mbean code="org.jboss.cache.CacheImpl"
                   name="jboss.cache:service=TreeCache">
                   <depends>jboss:service=Naming</depends>
                   <depends>jboss:service=TransactionManager</depends>
                   <attribute name="TransactionManagerLookupClass">JotmTxMgrLookup</attribute>
                   <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
                   <attribute name="CacheMode">REPL_SYNC</attribute>
                   <attribute name="UseReplQueue">false</attribute>
                   <attribute name="ReplQueueInterval">0</attribute>
                   <attribute name="ReplQueueMaxElements">0</attribute>
                   <attribute name="ClusterName">TestCluster</attribute>
                   <attribute name="UseInterceptorMbeans">true</attribute>
                   <attribute name="ClusterConfig">
                   <config>
                   <TCP start_port="8800"
                   loopback="true"
                   recv_buf_size="20000000"
                   send_buf_size="640000"
                   discard_incompatible_packets="true"
                   max_bundle_size="64000"
                   max_bundle_timeout="30"
                   use_incoming_packet_handler="true"
                   use_outgoing_packet_handler="false"
                   down_thread="false" up_thread="false"
                   enable_bundling="false"
                   use_send_queues="false"
                   sock_conn_timeout="300"
                   skip_suspected_members="true"/>
                   <TCPPING timeout="3000"
                   initial_hosts="127.0.0.1[8800]"
                   port_range="1"
                   num_initial_members="2"/>
                   <MERGE2 max_interval="100000"
                   min_interval="20000"/>
                   <FD_SOCK/>
                   <FD timeout="10000"
                   max_tries="5"
                   shun="true"/>
                   <VERIFY_SUSPECT timeout="1500" />
                   <pbcast.NAKACK max_xmit_size="60000"
                   use_mcast_xmit="false"
                   gc_lag="0"
                   retransmit_timeout="300,600,1200,2400,4800"
                   discard_delivered_msgs="true"/>
                   <pbcast.STABLE stability_delay="1000"
                   desired_avg_gossip="50000"
                   max_bytes="400000"/>
                   <pbcast.GMS print_local_addr="true"
                   join_timeout="3000"
                   join_retry_timeout="2000"
                   shun="false"
                   view_bundling="true"/>
                   <FRAG2 frag_size="60000" />
                   <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
                   <!-- <pbcast.STATE_TRANSFER/> -->
                   <pbcast.FLUSH/>
                   </config>
                   </attribute>
                   <attribute name="FetchInMemoryState">true</attribute>
                   <attribute name="StateRetrievalTimeout">15000</attribute>
                   <attribute name="SyncReplTimeout">15000</attribute>
                   <attribute name="LockAcquisitionTimeout">10000</attribute>
                   <attribute name="UseRegionBasedMarshalling">true</attribute>
                   </mbean>
                  </server>