javax.jcr.version.VersionException: OakVersion0001: Cannot change property jcr:lastModifiedBy on checked in node

ryaramala

24-04-2020

Hello All,

 

     Our project is being run on AEM 6.4 with SP7 service pack.

     Content authors are uploading the assets in bulk and after asset upload, they open each image and set few custom metadata(ex: asset expiration date).

     We have created a custom workflow for setting these custom metadatas.

     We have  configured workflow launcher to trigger this custom workflow (both on node:created and node:modified events)

 

     The issue we are facing here is : When user updates some metadata on image, dam-xmp-writeback workflow will be triggered (as it is configured in workflow launcher for node:modified event), at the same time our custom workflow is also triggered.

     Hence, for few assets, we are getting this exception javax.jcr.version.VersionException: Cannot set property. Node is checked in. since both the workflows will be trying to act upon the same payload  (/content/dam/*/assetname/jcr:content/metadata), and one of them will lock it and another won't get the resource at the same time.   

     Our business logic was written such that, if we get any such exception in the workflow process step, we are removing the metadata node for that asset.

     Say Suppose we upload some 10 images, 2-3 images are having this issue and their metadata nodes are getting removed, and authors are reporting that they are not able to open those images and edit them anymore(this is obvious since there is no metadata node for them).

 

     Now please suggest a way to handle this,

     Is there a way to avoid this version exception ? or should we modify the code such that we won't remove metadata node in exception scenario?

     Is it ok to disable xmp-writeback workflow on node:modified event?

 

     What would be the best way to handle this issue?

Below is the issue:

javax.jcr.version.VersionException: OakVersion0001: Cannot change property jcr:lastModifiedBy on checked in node
at org.apache.jackrabbit.oak.api.CommitFailedException.asRepositoryException(CommitFailedException.java:242) [org.apache.jackrabbit.oak-api:1.8.17]
at org.apache.jackrabbit.oak.api.CommitFailedException.asRepositoryException(CommitFailedException.java:213) [org.apache.jackrabbit.oak-api:1.8.17]
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.newRepositoryException(SessionDelegate.java:669) [org.apache.jackrabbit.oak-jcr:1.8.17]
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.save(SessionDelegate.java:495) [org.apache.jackrabbit.oak-jcr:1.8.17]
at org.apache.jackrabbit.oak.jcr.session.SessionImpl$8.performVoid(SessionImpl.java:420) [org.apache.jackrabbit.oak-jcr:1.8.17]
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.performVoid(SessionDelegate.java:273) [org.apache.jackrabbit.oak-jcr:1.8.17]
at org.apache.jackrabbit.oak.jcr.session.SessionImpl.save(SessionImpl.java:417) [org.apache.jackrabbit.oak-jcr:1.8.17]
at com.adobe.granite.repository.impl.CRX3SessionImpl.save(CRX3SessionImpl.java:208) [com.adobe.granite.repository:1.4.92]
at com.adobe.granite.workflow.core.WorkflowSessionImpl.persist(WorkflowSessionImpl.java:1469) [com.adobe.granite.workflow.core:2.0.168.CQ640-B0010]
at com.adobe.granite.workflow.core.job.JobHandler.process(JobHandler.java:394) [com.adobe.granite.workflow.core:2.0.168.CQ640-B0010]
at org.apache.sling.event.impl.jobs.JobConsumerManager$JobConsumerWrapper.process(JobConsumerManager.java:502) [org.apache.sling.event:4.2.12]
at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.startJob(JobQueueImpl.java:293) [org.apache.sling.event:4.2.12]
at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.access$100(JobQueueImpl.java:60) [org.apache.sling.event:4.2.12]
at org.apache.sling.event.impl.jobs.queues.JobQueueImpl$1.run(JobQueueImpl.java:229) [org.apache.sling.event:4.2.12]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.jackrabbit.oak.api.CommitFailedException: OakVersion0001: Cannot change property jcr:lastModifiedBy on checked in node
at org.apache.jackrabbit.oak.plugins.version.VersionEditor.throwCheckedIn(VersionEditor.java:252) [org.apache.jackrabbit.oak-core:1.8.17]
at org.apache.jackrabbit.oak.plugins.version.VersionEditor.propertyChanged(VersionEditor.java:132) [org.apache.jackrabbit.oak-core:1.8.17]
at org.apache.jackrabbit.oak.spi.commit.VisibleEditor.propertyChanged(VisibleEditor.java:73) [org.apache.jackrabbit.oak-store-spi:1.8.17]
at org.apache.jackrabbit.oak.spi.commit.EditorDiff.propertyChanged(EditorDiff.java:92) [org.apache.jackrabbit.oak-store-spi:1.8.17]
at org.apache.jackrabbit.oak.segment.SegmentNodeState.compareProperties(SegmentNodeState.java:630) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.segment.SegmentNodeState.compareAgainstBaseState(SegmentNodeState.java:524) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.spi.commit.EditorDiff.childNodeChanged(EditorDiff.java:147) [org.apache.jackrabbit.oak-store-spi:1.8.17]
at org.apache.jackrabbit.oak.segment.SegmentNodeState.compareAgainstBaseState(SegmentNodeState.java:564) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.spi.commit.EditorDiff.childNodeChanged(EditorDiff.java:147) [org.apache.jackrabbit.oak-store-spi:1.8.17]
at org.apache.jackrabbit.oak.segment.MapRecord.compare(MapRecord.java:422) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.segment.SegmentNodeState.compareAgainstBaseState(SegmentNodeState.java:617) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.spi.commit.EditorDiff.childNodeChanged(EditorDiff.java:147) [org.apache.jackrabbit.oak-store-spi:1.8.17]
at org.apache.jackrabbit.oak.segment.MapRecord.compare(MapRecord.java:422) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.segment.SegmentNodeState.compareAgainstBaseState(SegmentNodeState.java:617) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.spi.commit.EditorDiff.childNodeChanged(EditorDiff.java:147) [org.apache.jackrabbit.oak-store-spi:1.8.17]
at org.apache.jackrabbit.oak.segment.MapRecord.compare(MapRecord.java:422) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.segment.SegmentNodeState.compareAgainstBaseState(SegmentNodeState.java:617) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.spi.commit.EditorDiff.childNodeChanged(EditorDiff.java:147) [org.apache.jackrabbit.oak-store-spi:1.8.17]
at org.apache.jackrabbit.oak.segment.MapRecord.compare(MapRecord.java:422) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.segment.SegmentNodeState.compareAgainstBaseState(SegmentNodeState.java:617) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.spi.commit.EditorDiff.childNodeChanged(EditorDiff.java:147) [org.apache.jackrabbit.oak-store-spi:1.8.17]
at org.apache.jackrabbit.oak.segment.MapRecord$4.childNodeChanged(MapRecord.java:449) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.segment.MapRecord.compare(MapRecord.java:495) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.segment.MapRecord.compare(MapRecord.java:440) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.segment.SegmentNodeState.compareAgainstBaseState(SegmentNodeState.java:617) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.spi.commit.EditorDiff.process(EditorDiff.java:51) [org.apache.jackrabbit.oak-store-spi:1.8.17]
at org.apache.jackrabbit.oak.spi.commit.EditorHook.processCommit(EditorHook.java:54) [org.apache.jackrabbit.oak-store-spi:1.8.17]
at org.apache.jackrabbit.oak.spi.commit.CompositeHook.processCommit(CompositeHook.java:60) [org.apache.jackrabbit.oak-store-spi:1.8.17]
at org.apache.jackrabbit.oak.plugins.version.VersionHook.processCommit(VersionHook.java:86) [org.apache.jackrabbit.oak-core:1.8.17]
at org.apache.jackrabbit.oak.spi.commit.CompositeHook.processCommit(CompositeHook.java:60) [org.apache.jackrabbit.oak-store-spi:1.8.17]
at org.apache.jackrabbit.oak.spi.commit.CompositeHook.processCommit(CompositeHook.java:60) [org.apache.jackrabbit.oak-store-spi:1.8.17]
at org.apache.jackrabbit.oak.segment.scheduler.Commit.apply(Commit.java:105) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.segment.scheduler.LockBasedScheduler.execute(LockBasedScheduler.java:322) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.segment.scheduler.LockBasedScheduler.schedule(LockBasedScheduler.java:292) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.segment.SegmentNodeStore.merge(SegmentNodeStore.java:193) [org.apache.jackrabbit.oak-segment-tar:1.8.17]
at org.apache.jackrabbit.oak.core.MutableRoot.commit(MutableRoot.java:250) [org.apache.jackrabbit.oak-core:1.8.17]
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.commit(SessionDelegate.java:346) [org.apache.jackrabbit.oak-jcr:1.8.17]
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.save(SessionDelegate.java:493) [org.apache.jackrabbit.oak-jcr:1.8.17]
... 13 common frames omitted

Accepted Solutions (1)

Accepted Solutions (1)

Arun_Patidar

MVP

24-04-2020

In your custom workflow check if node is already check in then wait and check node check in property again after 5 sec (until node is not unlocked/or max 10 min.) and try to execute your own logic. Implementing via threading can help.

Answers (0)