Encountered activationStatus has been modified externally when publishing

197 views Asked by At

I'm doing an update for multiple nodes and then a batch publish (a lot of data) using the command "Activate" to publish the nodes programmatically but sometimes I don't know why I will get an error sometimes. It only happened for few times so far so I find it hard to figure out what's the one causing the issue.

Here is the error thrown.

Caused by: org.apache.jackrabbit.core.state.StaleItemStateException: 8b3ce2d4-eb7b-4838-901c-413aa9eeee84/{http://www.magnolia.info/jcr/mgnl}activationStatus has been modified externally
    at org.apache.jackrabbit.core.ItemSaveOperation.removeTransientItems(ItemSaveOperation.java:723)
    at org.apache.jackrabbit.core.ItemSaveOperation.perform(ItemSaveOperation.java:228)

Have anyone encountered a similar issue? Or any idea where to look at this issue?

Thanks! :)

1

There are 1 answers

1
Ducaz035 On BEST ANSWER

Basically update operation internally cause Magnolia to modify the activation state (which is correct). When this operation is ongoing the update operation is taking over and attempting to change the state. In this case if you are unlucky you might hit the exception you got. Reasoning being is that those commands run async but touch the same nodes.

Potential Solution:

1) You may simply give some time for the first operation to complete and execute the second one after.

2) This needs some development effort but here we go:

You may use LockManager to lock the nodes being used by the first operation and unlock it when the operation is done completely. Second operation meanwhile will check if the nodes are locked and if yes will not continue but wait till its unlocked from the first process.