Issue
The video upload system was incorrectly prioritizing parts from newer series over older ones, resulting in an interleaved upload pattern instead of completing older series first. For example, a 31-part series created earlier might have its parts mixed with a newer 17-part series, producing an upload order like of-17 part 1, of-31 part 1, of-17 part 2 rather than finishing the older series entirely.
Culprit
The sorting mechanism for the upload queue relied on a tuple-based comparison that prioritized series with fewer total parts over older series. Specifically, the comparison logic (0, series_part, series_total, creation_time) caused newer series with fewer parts to be processed first, as the series_total value was evaluated before creation_time in tuple comparisons.
Solution
The sort key was restructured to prioritize creation_time first, ensuring the oldest series is completed before newer ones begin. The tuple format was changed to (0, creation_time, series_part, series_total).
This required updates to all references to the priority tuple indices in the system to maintain consistency.
Result: The system now processes all parts of older series sequentially before starting newer series, with correct part ordering within each series.