Add Course enrollment change transaction handling #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
An issue was detected in the asynchronous execution of tasks related to the Course enrollment logic in the plugin. There is a chance that the model query runs before the object is committed to the database. Since the view triggering the task is wrapped in an atomic operation, the task may execute before the commit is finalized, resulting in the object being unavailable.
More information about this issue can be found here, While the community is exploring an alternative approach to sink integration, we will address the issue by adjusting the precise timing of the task execution.
Proposed Change:
We propose modifying the task execution so that it occurs only after the transaction has been fully committed. By leveraging the transaction.on_commit method, we can wrap the task call to ensure it executes only once the database has been successfully updated