Hi
Based on the details shared it will be difficult to provide a solution but you can check below to diagnose and resolve this issue
Check for Exceptions in error Logs:
Look into the error logs for any exceptions or errors related to your servlet, Sling job, or service class. Any errors in the logs might provide valuable information about what's going wrong.
Ensure Proper Configuration:
Verify that your Sling job, servlet, and service class are properly configured and registered in the OSGi container. Make sure that the configuration is consistent and correctly set up.
Synchronize Concurrent Access:
If your servlet or Sling job involves shared data or resources that could be accessed concurrently, make sure you handle concurrency properly. Using synchronization mechanisms like synchronized blocks or leveraging OSGi services for concurrency management can help prevent issues.
Verify Thread Safety:
Ensure that your code within the servlet, Sling job, and service class is thread-safe. Concurrent access to non-thread-safe code can lead to unpredictable behavior.
Check for Session or Request-Specific State:
If your code relies on session-specific or request-specific state, make sure that this state is properly managed and doesn't cause issues when processing subsequent requests. Using request attributes or thread-local variables can help isolate request-specific data.
Clear Caches:
Sometimes, issues related to OSGi configurations or bundle deployments can be resolved by clearing the caches. Try clearing the AEM OSGi bundle cache and see if it resolves the problem.
Review Configuration Changes:
Check if any configuration changes were made between the first and second servlet hits. A change in configuration might affect the behavior of your components.