Ensure on_demand content finishes saving before request completes
With #8980 a race condition was found from a client requesting on_demand content and closing the connection after downloading the content before the artifact was finished being saved to the database. The fix in https://github.com/pulp/pulpcore/pull/1447 ensures that the async save task isn't canceled, but a race condition is still present if a client closes the connection before the save is complete and then requests the artifact from the database. They will see no artifact present despite the fact the artifact is still being saved. The timing for this race condition is pretty tight for most artifacts and probably won't be experienced in any normal workflows.
The solution to remove this race condition is to wait before sending the last_chunk for the StreamedResponse like this https://github.com/pulp/pulpcore/commit/cd76a36ae74f98bb19bebe29a0db3e0879010028. This change would require changes in other plugins that define their own Downloaders and it is possible this condition isn't prevalent enough to warrant the work.
Please register to edit this issue