Concurrency issue on event handler | Community
Skip to main content
Level 1
April 9, 2026
Question

Concurrency issue on event handler

  • April 9, 2026
  • 1 reply
  • 12 views

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:

  1. Unpublish page by removing manually via CRX and publish again 
  2. Checked the /system/console/status-jstack-threaddump
    1. Here all threads of type EventAdminAsyncThread have been in RUNNABLE state
    2. 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

    1 reply

    VishalKa5
    Level 6
    April 10, 2026

    Hi ​@RazvanParautiu,

    This looks like a concurrency issue caused by multiple event threads trying to replicate the same page at the same time.

    1. Multiple events (PageEvent, ReplicationEvent, ReplicationActionEvent) may trigger duplicate replication for the same page.
    2. This causes parallel writes on the same node, leading to OakState0001 conflicts.
    3. The SessionDelegate warning means the same content is being accessed concurrently by different threads.
    4. Even with new ResourceResolvers, conflicts happen if the same page is updated simultaneously.
    5. Add logging to track duplicate event triggers for the same path.
    6. Avoid recursive replication loops from replication events.
    7. Use filtering/queueing so only one replication per page runs at a time.

    In short: the problem is most likely duplicate parallel replication on the same page, not the replicator API itself.

    Thanks & Regards,

    Vishal