cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with secondary parent associations in cluster

francescof
Champ in-the-making
Champ in-the-making
Hi,

I have a problem with parent associations in my clustered setup (Alfresco 2.1 Community on a JBoss 4.0.5 2-node cluster): newly created nodes and their (primary) parent associations are replicated correctly. Secondary parent assocs are not.

HibernateNodeDaoServiceImpl.java look like this in 2.1 Community Final (line s from 990 to 1003):


            for (Long parentAssocId : parentAssocIds)
            {
                ChildAssoc parentAssoc = (ChildAssoc) getSession().get(ChildAssocImpl.class, parentAssocId);
                if (parentAssoc == null)
                {
                    // The cache is out of date, so just repopulate it
                    parentAssoc = null;
                    break;
                }
                else
                {
                    parentAssocs.add(parentAssoc);
                }
            }

I suppose the assigment "parentAssoc = null" should be "parentAssocs = null" and, if I'm right, that typo prevents assocs that are no longer in the DB from being expired from cache. What I can't figure out is whether this bug also influences correct propagation of new secondary child associations to other cluster nodes.

I also found a JIRA issue related to this part of the code: http://issues.alfresco.com/browse/AR-1743

Any ideas?

(Please note that after a fresh restart of the cluster I can see all the associations from all of the nodes.)
2 REPLIES 2

francescof
Champ in-the-making
Champ in-the-making
After deeper investigations I think I have identified the cause of the problem.

I noticed that, after a secondary child assoc creation no transaction is recorded on alf_transaction because newChildAssoc() and deleteChildAssocInternal() in HibernateNodeDaoServiceImpl don't update NodeStatus for the modified node. This way the remote node of the cluster doesn't know anything about the new child association and thus it doesn't update its lucene indexes.

A quick hack that seems to do the job is to add (with a check to execute this code ONLY on non-primary child-assocs) to newChildAssoc() and deleteChildAssocInternal():

NodeStatus nodeStatus = getNodeStatus(nodeRef, true);

nodeStatus.getTransaction().setChangeTxnId(AlfrescoTransactionSupport.getTransactionId());

This way alf_transaction and alf_node_status tables get updated, the remote node updates its lucene indexes and the secondary association is correctly viewable on the remote node web client.

My concern is: is it possible that this change carries dangerous side effects? I'm thinking about possible index corruption. I'm also aware that the hack described is not the best and cleanest solution for the problem. Have you any suggestions for improvements?

Bye.

derek
Star Contributor
Star Contributor
Hi,

You are correct on all counts.

The node status updates are all in the NodeService implementation and should really be at that level i.e. nodeDaoService.recordChangeId(nodeRef);.  I'll have to play with it a bit to check if there are any further issues.  http://issues.alfresco.com/browse/AR-1777

Regards