How questionnaire schedule generation works is that for each assessment in the protocol, parallel streams are used to generate tasks. Previously, within each stream, the tasks are saved in the database. However, there are issues when the schedule generation occurs right after changes in the database are made (e.g. User entity creation/changes). The db changes are not seen by the thread that's generating the tasks because the code in the threads will not be a part of the original transaction (where the db changes occurred).
This solves the issue by moving the saving of the tasks outside the parallel streams (after all tasks are generated, as opposed to saving them as they are generated).