Upgrade scripts performances
During the 8.3.0 upgrade process, the 1070-video-first-published-at.js migration script took more than 30 minutes on one of my instances.
(number of rows in the video table: 590805)
Looking at the code: https://github.com/Chocobozzz/PeerTube/blob/faa76bad2c1969a088ef1df38dc666dfe7259b5c/server/core/initializers/migrations/1070-video-first-published-at.ts#L15-L17
The request is pretty easy, and should be done in seconds... I think that the bottleneck is because of the transaction. I guess this force PostGresql to rewrite the entire table (i'm not sure, i did not test, it is only an hypothesis). Using a transaction in such migration scripts seems not really useful:
- peertube is not running at this point
- even if the request is interrupted, it could be run again without issue. The request is constructed in a way that it will only process lines that were not already processed.
I'm not opening this issue for this specific migration (too late, version 8.3.0 is already published), but to suggest avoiding using transaction in such script, when it is not needed.
Or maybe i missed something?
Source: Chocobozzz/PeerTube