I have the following service, which gets called using quarkus's Scheduler using the @Scheduled
annotation.
The basic idea is that this lists the pending tasks, and then uses the ExecutorService
to run the individual tasks.
I get warning logs as follows:
[co.ar.at.arjuna] checkChildren ARJUNA012094: Commit of action id 0:ffffc0a80e70:8b9b:5f2d31f1:5b invoked while multiple threads active within it.
WARN [co.ar.at.arjuna] check ARJUNA012107: CheckedAction::check - atomic action 0:ffffc0a80e70:8b9b:5f2d31f1:5b commiting with 2 threads active!
What is the reason for this and what can I do to fix this? My primary goal is to get off the Scheduler thread as soon as I can and let the task updation happen in the background
@RequestScoped
@Transactional(REQUIRED)
public class TaskService {
@Inject
ManagedExecutor executor;
public void runPendingTasks() {
final List<Task> taskList = Task.list("pending=?1 ",true);
logger.debug("Found " + taskList.size() + " tasks pending ");
for (final Task task : taskList) {
executor.execute(() -> {
final boolean status = doTask(task);
});
}
}
@Transactional(REQUIRED)
private boolean doTask(final Task task) {
logger.debug("Going to run task " + task.getId() );
//Do some DB updation here
return true;
}
}