Fix project transfer failure in some circumstances #5135
Merged
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
Fix an error when project is not transferred entirely to the new owner and data is missing under the account of the new owner.
Project returns the correct number of submissions, but the table view only returns a subset of it.
Notes
A new management command has been added to resume broken transfers done after
2.024.25
release has been deployed:resume_failed_transfers_2_024_25_fix
The main problem was a race condition between uWSGI process and Celery process. The PR ensures that Celery tasks are triggered IFF data in transaction is saved in DB, thanks to
transaction.on_commit
hook.Moreover,
media_file
field ofAttachment
model is changed toExtendedField
like it is in its shadow model counterpart (i.e.:KobocatAttachment
). It provides the methodmove()
which is required by transfer asynchronous tasks. See https://github.com/kobotoolbox/kpi/blob/834ec518a9487dcfacd51e2476f1ad6fafda041c/kpi/fields/file.py for more details.