Bug #106318
openParallel execution of single-execution Scheduler Task
0%
Description
When there are multiple workers processing Schedule Module Tasks, the same task may be executed multiple times in parallel even if "Allow Parallel Execution" is disabled on the task.
This is because of a Time-of-Check Time-of-Use style issue in the implementation. Scheduler::execute() indirectly causes three queries that are relevant to the functionality that prevents parallel execution of non-parallel tasks:
1. SELECT in SchedulerTaskRepository::isTaskMarkedAsRunning() to check if there's any execution on the task
2. SELECT in SchedulerTaskRepository::addExecutionToTask() to get the lastest execution map
3. UPDATE in SchedulerTaskRepository::addExecutionToTask() to replace the execution map
All parallel processes whose first SELECT query hits before any process' UPDATE statement continue to actually execute the task.
There is another time window in SchedulerTaskRepository::addExecutionToTask() and SchedulerTaskRepository::removeExecutionOfTask() that causes parallel additions and removals to not function properly. Given the following scenario where two processes execute the same of the two methods:
1. Process 1 executes the SELECT to determine the base serialized_executions
2. Process 2 executes the SELECT to determine the base serialized_executions
3. Process 1 executes the UPDATE to save the new serialized_executions
4. Process 2 executes the UPDATE to save the new serialized_executions
The update (addition or removal) tried by Process 1 will be overwritten by Process 2.
A full reproduction example for TYPO3 v13, v12 and v11 is available on GitHub: https://github.com/adamkoppede/typo3-parallel-scheduler-task-processing-test
Updated by Gerrit Code Review 5 days ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/88556
Updated by Gerrit Code Review 5 days ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/88556
Updated by Gerrit Code Review 5 days ago
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/88556