Thursday, February 23, 2012

Issue with invalidating caches at regular intervals

After setting some values in an item & before calling updateItem on that item, if that particular repository cache is invalidated then the changes made to item in that transaction are lost/not updated.

And in logs you will see something like
Changes not updated for item in commit: <item-descriptor-name>:<id-of-item> changes={<property-name>=<value-that-being-set>}

For example -
Suppose there is www_person table in /com/person/PersonRepository

public boolean handleUpdate(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse) throws Exception {
MutableRepositoryItem personItem = personRepository.getItemForUpdate("100001");
personItem.setPropertyValue("lastname", "Mike");

// Invalidate cache at this point, as you can observe last value set is lost. 
logInfo("Last name"+(String) personItem.getPropertyValue("lastname"));

personRepository.updateItem(personItem);
return true;
}

Refer below screenshot - 

In logs -
**** Error      Thu Feb 23 18:21:12 CST 2012    1330042872864   /       Changes not updated for item in commit: person:100001 changes={lastname=Mike}

If you have some cron jobs which are invalidating repositories in regular intervals, then above type of errors may occur.

For example - If you have cron job for invalidating OrderRepository at regular intervals, then the values set to order item or commerce item or shipping item will be lost or not updated if invalidate cache is called before updateOrder/UpdateItem method.

ATG/Oracle support created a patch regarding this issue.

Hope this helps.

1 comment:

  1. It was very nice article and it is very useful to Oracle ATG Commerce learners.We also provide Cub training software online training.

    ReplyDelete