AnsweredAssumed Answered

When should NodeStatus (alf_node_status table) be updated?

Question asked by francescof on Sep 26, 2007
Latest reply on Oct 15, 2007 by francescof
I'm asking the question "when should NodeStatus (alf_node_status table) be updated?" because I ran in the same problem two times in a few days.

The first is described here: http://forums.alfresco.com/viewtopic.php?t=8772

The second is similar, and has a similar solution…

I noticed that, in a two node clustered environment, if I update properties on a node calling setProperties() API from NodeService, the results from a XPath/Lucene search on the remote node (with respect to the node where the change was performed) don't reflect the new value.

Example:
    * Content cm:foo has cm:author = Alice.
    * Call setProperties() on node 1 to set cm:author = Bob on content cm:Foo.
    * getProperties() on XPath/Lucene search results on node 1 shows cm:author = Bob, on node 2 shows cm:author = Alice.
    * Web client "show details" on cm:Foo shows cm:author = Bob on both nodes.
Looking through the code in DbNodeServiceImpl I noticed that setPropertiesImpl() calls nodeDaoService.recordChangeId(nodeRef).

From HibernateNodeDaoServiceImpl.java:

    public void recordChangeId(NodeRef nodeRef)
    {
        NodeKey key = new NodeKey(nodeRef);
       
        NodeStatus status = (NodeStatus) getHibernateTemplate().get(NodeStatusImpl.class, key);
        if (status == null)
        {
            // the node never existed or the status was deleted
            return;
        }
        else
        {
            // make sure that the status has the latest transaction attached
            Transaction currentTxn = getCurrentTransaction();
            status.setTransaction(currentTxn);
        }
    }

But this is not sufficient to force a node reindex on the remote node. I added the following line after status.setTransaction(currentTxn):


    getHibernateTemplate().saveOrUpdate(status);

Now I can see the updates on both nodes. Once again I'm asking if this change is likely to break other things.

What's your opinion?

Outcomes