Concurrency issue on event handler
We have on premise AEM (6.5) author and publiser instance and during last 2-3 days our error.log file is full of following errors on publisher instance
- OakState0001 errors
09.04.2026 13:37:45.729 *ERROR* [55.32.21.101 [1775734665631] POST /bin/receive HTTP/1.1] com.day.cq.replication.impl.servlets.ReplicationServlet Error during replication: Repository error during node import: OakState0001: Unresolved conflicts in /content/some-page/jcr:content
com.day.cq.replication.ReplicationException: Repository error during node import: OakState0001: Unresolved conflicts in /content/some-page/jcr:content
Caused by: javax.jcr.InvalidItemStateException: OakState0001: Unresolved conflicts in /content/some-page/jcr:content
Caused by: org.apache.jackrabbit.oak.api.CommitFailedException: OakState0001: Unresolved conflicts in /content/some-page/jcr:content
- Concurrency warning
09.04.2026 14:50:46.659 *WARN* [EventAdminAsyncThread #9] org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate Attempted to perform getItemOrNull while thread EventAdminAsyncThread #10 was concurrently writing to this session. Blocked until the other thread finished using this session. Please review your code to avoid concurrent use of a session.
to be mentioned that this warning from SessionDelegate is displayed everytime when SessionDelegate tries to aquire the lock during method calls like getItemOrNull, isNodeType, etc (all methods which require synchronization)
The context
This is happening during page publishing on Publisher instance and I will try to describe our flow.
1. Everything starts from an EventHandler which is listening on:
- PageEvent.EVENT_TOPIC,
- ReplicationEvent.EVENT_TOPIC,
- ReplicationAction.EVENT_TOPIC
2. Inside of handleEvent method we are calling
replicationTrigger.triggerReplication(path, type);
3. Inside of triggerReplication method we are calling the
try (ResourceResolver resolver = new ResourceResolverSecurity(resolverFactory, ResourceResolverSecurity.SubserviceUser.REPLICATION_SERVICE_USER).getSpecifiedResourceResolver()) {
Session session = resolver.adaptTo(Session.class);
replicator.replicate(session, type, path, replicationOptions);
}so the session is aquired from a new ResourceResolver
4. This replicator via replicate method is calling the related Agent which is reponsible for the given page
5. A TransportHandler implementation is invoked and the content is delivered to disk
From debugging what I saw is that this part is handled by other threads from some ThreadPool (not on the session passed to replicator)
Also to be mentioned that not on all pages this is happening and also only on one environemnt where we have same code as we have it on another env where this issue is not happening.
What we tried so far:
- Unpublish page by removing manually via CRX and publish again
- Checked the /system/console/status-jstack-threaddump
- Here all threads of type EventAdminAsyncThread have been in RUNNABLE state
- restarted the server and now all threads are in WAITING but same errors occurs in console
Any ideeas what can we do a step by step debugging or for what we can look for, because from my understanding, that SessionDelegator is shared at some point by 2 threads and since one thread aquired the lock, we have that warning message https://github.com/apache/jackrabbit-oak/blob/4b8fe706c52851ac063e2753f473a77738fc4104/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java#L813
Also from my understanding this errors are happening during EventHandler since an EventAdminAsyncThread is bound to this process, but what I dont understand is where exactly in our code this session is shared, because everything is statefull?
Only place where the session is passed is from eventHandler via replicator.replicate method, but again, that session is aquired from a new resource resolver (see code)
If someone has any ideea to what else we can looking for would be great.
Thanks in advice,
Razvan