Expand my Community achievements bar.

SOLVED

Blocked until the other thread finished using this session, concurrent use of session issue.

Avatar

Level 3

The following warning displays frequently:

 

03.07.2023 18:39:14.610 *WARN* [10.43.0.119 [1688434753476] GET /content/torrid/review-dashboard.40740719.11370.html HTTP/1.1] org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate Attempted to perform getItemOrNull while thread 10.43.0.119 [1688434753887] GET /content/torrid/review-dashboard.40740633.html HTTP/1.1 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.

 

Any assistance regarding the issue is appreciated.

 

 

Thank you,

Nandan

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

hello @nandan123 

 

Please refer to the blog https://cqdump.joerghoh.de/2015/03/02/aem-scaling-patterns-avoid-shared-sessions/ 

 

We need to avoid Session sharing between multiple threads. Each thread should use its own individual session.

 

The Blog also contains link to an example. 

 

Hope it helps


Aanchal Sikka

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

hello @nandan123 

 

Please refer to the blog https://cqdump.joerghoh.de/2015/03/02/aem-scaling-patterns-avoid-shared-sessions/ 

 

We need to avoid Session sharing between multiple threads. Each thread should use its own individual session.

 

The Blog also contains link to an example. 

 

Hope it helps


Aanchal Sikka

Avatar

Employee

if you have created a servlet and resource resolver is not thread safe (servlet instance variable) then you can face this issue. create resource resolve / session in doGet or doPost methods and then close at the end.

 

if you are using service and creating instance variable for resource resolver / session then it will create this issue. create resource resolver /session in the service method and close at the end.

Avatar

Community Advisor

Hello @nandan123  - 

 

The warning message you provided indicates a concurrent use of a session in AEM, which can lead to potential issues or conflicts. Few suggestions to address :

 

1. Most important : Examine your codebase and identify areas where multiple threads or requests may be accessing the same session concurrently. Look for scenarios where sessions are shared or accessed simultaneously without proper synchronization.

 

2. Ensure that sessions are not shared across threads or requests unless absolutely necessary. Each thread or request should have its own dedicated session to avoid conflicts. It's best to acquire a session when it's needed and release it as soon as it's no longer required.

 

3. If multiple threads or requests need to access the same session, implement proper synchronization mechanisms to ensure thread safety. This can be achieved using locks, mutexes, or other concurrency control mechanisms provided by the programming language or framework you're using.

 

4. Check if your code utilizes a thread-safe session handling mechanism provided by AEM or any custom implementation. AEM provides `ResourceResolver` and `ResourceResolverFactory` interfaces that offer thread-safe session management. Ensure that you're using these interfaces appropriately to handle sessions in a thread-safe manner.

 

5. Monitor your AEM instance and analyze thread usage patterns. Identify any long-running or blocking threads that may contribute to concurrent session usage. This analysis can help pinpoint specific areas of your code or AEM components that need attention.