aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-08-09 13:21:18 +0200
committerChocobozzz <me@florianbigard.com>2022-08-09 13:21:18 +0200
commit51335c72cf1119a92901edeaa5c7dfc1feef3ca4 (patch)
tree024091083b237ade367b63af8c48c4d7e027fa62 /server/lib
parente2b2c726b1c1c31794d324c3afd7c24e1f953131 (diff)
downloadPeerTube-51335c72cf1119a92901edeaa5c7dfc1feef3ca4.tar.gz
PeerTube-51335c72cf1119a92901edeaa5c7dfc1feef3ca4.tar.zst
PeerTube-51335c72cf1119a92901edeaa5c7dfc1feef3ca4.zip
Prevent job failure on concurrent HLS transcoding
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/hls.ts22
-rw-r--r--server/lib/job-queue/handlers/video-transcoding.ts2
-rw-r--r--server/lib/job-queue/job-queue.ts6
3 files changed, 15 insertions, 15 deletions
diff --git a/server/lib/hls.ts b/server/lib/hls.ts
index ad29e4c90..9ec931b4f 100644
--- a/server/lib/hls.ts
+++ b/server/lib/hls.ts
@@ -35,15 +35,19 @@ async function updateStreamingPlaylistsInfohashesIfNeeded () {
35} 35}
36 36
37async function updatePlaylistAfterFileChange (video: MVideo, playlist: MStreamingPlaylist) { 37async function updatePlaylistAfterFileChange (video: MVideo, playlist: MStreamingPlaylist) {
38 let playlistWithFiles = await updateMasterHLSPlaylist(video, playlist) 38 try {
39 playlistWithFiles = await updateSha256VODSegments(video, playlist) 39 let playlistWithFiles = await updateMasterHLSPlaylist(video, playlist)
40 40 playlistWithFiles = await updateSha256VODSegments(video, playlist)
41 // Refresh playlist, operations can take some time 41
42 playlistWithFiles = await VideoStreamingPlaylistModel.loadWithVideoAndFiles(playlist.id) 42 // Refresh playlist, operations can take some time
43 playlistWithFiles.assignP2PMediaLoaderInfoHashes(video, playlistWithFiles.VideoFiles) 43 playlistWithFiles = await VideoStreamingPlaylistModel.loadWithVideoAndFiles(playlist.id)
44 await playlistWithFiles.save() 44 playlistWithFiles.assignP2PMediaLoaderInfoHashes(video, playlistWithFiles.VideoFiles)
45 45 await playlistWithFiles.save()
46 video.setHLSPlaylist(playlistWithFiles) 46
47 video.setHLSPlaylist(playlistWithFiles)
48 } catch (err) {
49 logger.info('Cannot update playlist after file change. Maybe due to concurrent transcoding', { err })
50 }
47} 51}
48 52
49// --------------------------------------------------------------------------- 53// ---------------------------------------------------------------------------
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts
index cb2978157..b0e92acf7 100644
--- a/server/lib/job-queue/handlers/video-transcoding.ts
+++ b/server/lib/job-queue/handlers/video-transcoding.ts
@@ -42,7 +42,7 @@ const lTags = loggerTagsFactory('transcoding')
42 42
43async function processVideoTranscoding (job: Job) { 43async function processVideoTranscoding (job: Job) {
44 const payload = job.data as VideoTranscodingPayload 44 const payload = job.data as VideoTranscodingPayload
45 logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID)) 45 logger.info('Processing transcoding job %s.', job.id, lTags(payload.videoUUID))
46 46
47 const video = await VideoModel.loadFull(payload.videoUUID) 47 const video = await VideoModel.loadFull(payload.videoUUID)
48 // No video, maybe deleted? 48 // No video, maybe deleted?
diff --git a/server/lib/job-queue/job-queue.ts b/server/lib/job-queue/job-queue.ts
index 14e3a00aa..281e2e51a 100644
--- a/server/lib/job-queue/job-queue.ts
+++ b/server/lib/job-queue/job-queue.ts
@@ -286,20 +286,16 @@ class JobQueue {
286 async pause () { 286 async pause () {
287 for (const handlerName of Object.keys(this.workers)) { 287 for (const handlerName of Object.keys(this.workers)) {
288 const worker: Worker = this.workers[handlerName] 288 const worker: Worker = this.workers[handlerName]
289 const queue: Queue = this.queues[handlerName]
290 289
291 await worker.pause() 290 await worker.pause()
292 await queue.pause()
293 } 291 }
294 } 292 }
295 293
296 async resume () { 294 resume () {
297 for (const handlerName of Object.keys(this.workers)) { 295 for (const handlerName of Object.keys(this.workers)) {
298 const worker: Worker = this.workers[handlerName] 296 const worker: Worker = this.workers[handlerName]
299 const queue: Queue = this.queues[handlerName]
300 297
301 worker.resume() 298 worker.resume()
302 await queue.resume()
303 } 299 }
304 } 300 }
305 301