1
0
Fork 0

Prevent job failure on concurrent HLS transcoding

This commit is contained in:
Chocobozzz 2022-08-09 13:21:18 +02:00
parent e2b2c726b1
commit 51335c72cf
No known key found for this signature in database
GPG key ID: 583A612D890159BE
3 changed files with 13 additions and 13 deletions

View file

@ -35,15 +35,19 @@ async function updateStreamingPlaylistsInfohashesIfNeeded () {
} }
async function updatePlaylistAfterFileChange (video: MVideo, playlist: MStreamingPlaylist) { async function updatePlaylistAfterFileChange (video: MVideo, playlist: MStreamingPlaylist) {
let playlistWithFiles = await updateMasterHLSPlaylist(video, playlist) try {
playlistWithFiles = await updateSha256VODSegments(video, playlist) let playlistWithFiles = await updateMasterHLSPlaylist(video, playlist)
playlistWithFiles = await updateSha256VODSegments(video, playlist)
// Refresh playlist, operations can take some time // Refresh playlist, operations can take some time
playlistWithFiles = await VideoStreamingPlaylistModel.loadWithVideoAndFiles(playlist.id) playlistWithFiles = await VideoStreamingPlaylistModel.loadWithVideoAndFiles(playlist.id)
playlistWithFiles.assignP2PMediaLoaderInfoHashes(video, playlistWithFiles.VideoFiles) playlistWithFiles.assignP2PMediaLoaderInfoHashes(video, playlistWithFiles.VideoFiles)
await playlistWithFiles.save() await playlistWithFiles.save()
video.setHLSPlaylist(playlistWithFiles) video.setHLSPlaylist(playlistWithFiles)
} catch (err) {
logger.info('Cannot update playlist after file change. Maybe due to concurrent transcoding', { err })
}
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View file

@ -42,7 +42,7 @@ const lTags = loggerTagsFactory('transcoding')
async function processVideoTranscoding (job: Job) { async function processVideoTranscoding (job: Job) {
const payload = job.data as VideoTranscodingPayload const payload = job.data as VideoTranscodingPayload
logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID)) logger.info('Processing transcoding job %s.', job.id, lTags(payload.videoUUID))
const video = await VideoModel.loadFull(payload.videoUUID) const video = await VideoModel.loadFull(payload.videoUUID)
// No video, maybe deleted? // No video, maybe deleted?

View file

@ -286,20 +286,16 @@ class JobQueue {
async pause () { async pause () {
for (const handlerName of Object.keys(this.workers)) { for (const handlerName of Object.keys(this.workers)) {
const worker: Worker = this.workers[handlerName] const worker: Worker = this.workers[handlerName]
const queue: Queue = this.queues[handlerName]
await worker.pause() await worker.pause()
await queue.pause()
} }
} }
async resume () { resume () {
for (const handlerName of Object.keys(this.workers)) { for (const handlerName of Object.keys(this.workers)) {
const worker: Worker = this.workers[handlerName] const worker: Worker = this.workers[handlerName]
const queue: Queue = this.queues[handlerName]
worker.resume() worker.resume()
await queue.resume()
} }
} }