Episode#publish! and Podcast#publish! are assumed to be idempotent, however there is a race in the initialization routine Episode#publish! and the delegated delivery publishing machinery.
1) The call to Episode#publish! happens outside the publishing lock. This call prepares the episode for re-upload by soft deleting the Apple::Delivery instances associated with this episode. This is needed because a new delivery instance is needed for each upload process.
2) The delegated delivery process depends on the Apple::PodcastDelivery instance, e.g. in the case where we are polling for delivery state.
Episode#publish! and Podcast#publish! are assumed to be idempotent, however there is a race in the initialization routine
Episode#publish!
and the delegated delivery publishing machinery.1) The call to
Episode#publish!
happens outside the publishing lock. This call prepares the episode for re-upload by soft deleting the Apple::Delivery instances associated with this episode. This is needed because a new delivery instance is needed for each upload process.2) The delegated delivery process depends on the Apple::PodcastDelivery instance, e.g. in the case where we are polling for delivery state.
What can happen is that the episode is published and a publishing pipeline begins and then is quickly edited again, this in turn causes a soft deleting the podcast delivery instances (as legacy of treating them as sentinels), which causes related models to blow up when they follow their object hierarchy.