Fix pending transcoding with failed job
This commit is contained in:
parent
453537426a
commit
025d858e79
|
@ -53,6 +53,7 @@ async function processVideoTranscoding (job: Job) {
|
||||||
|
|
||||||
if (!handler) {
|
if (!handler) {
|
||||||
await moveToFailedTranscodingState(video)
|
await moveToFailedTranscodingState(video)
|
||||||
|
await VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode')
|
||||||
|
|
||||||
throw new Error('Cannot find transcoding handler for ' + payload.type)
|
throw new Error('Cannot find transcoding handler for ' + payload.type)
|
||||||
}
|
}
|
||||||
|
@ -62,12 +63,20 @@ async function processVideoTranscoding (job: Job) {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await moveToFailedTranscodingState(video)
|
await moveToFailedTranscodingState(video)
|
||||||
|
|
||||||
|
await VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode')
|
||||||
|
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|
||||||
return video
|
return video
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export {
|
||||||
|
processVideoTranscoding
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Job handlers
|
// Job handlers
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -119,7 +128,7 @@ async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTrans
|
||||||
|
|
||||||
logger.info('Merge audio transcoding job for %s ended.', video.uuid, lTags(video.uuid))
|
logger.info('Merge audio transcoding job for %s ended.', video.uuid, lTags(video.uuid))
|
||||||
|
|
||||||
await onVideoFileOptimizer(video, payload, 'video', user)
|
await onVideoFirstWebTorrentTranscoding(video, payload, 'video', user)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {
|
async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {
|
||||||
|
@ -129,7 +138,7 @@ async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodi
|
||||||
|
|
||||||
logger.info('Optimize transcoding job for %s ended.', video.uuid, lTags(video.uuid))
|
logger.info('Optimize transcoding job for %s ended.', video.uuid, lTags(video.uuid))
|
||||||
|
|
||||||
await onVideoFileOptimizer(video, payload, transcodeType, user)
|
await onVideoFirstWebTorrentTranscoding(video, payload, transcodeType, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -159,7 +168,7 @@ async function onHlsPlaylistGeneration (video: MVideoFullLight, user: MUser, pay
|
||||||
await retryTransactionWrapper(moveToNextState, video, payload.isNewVideo)
|
await retryTransactionWrapper(moveToNextState, video, payload.isNewVideo)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onVideoFileOptimizer (
|
async function onVideoFirstWebTorrentTranscoding (
|
||||||
videoArg: MVideoWithFile,
|
videoArg: MVideoWithFile,
|
||||||
payload: OptimizeTranscodingPayload | MergeAudioTranscodingPayload,
|
payload: OptimizeTranscodingPayload | MergeAudioTranscodingPayload,
|
||||||
transcodeType: TranscodeOptionsType,
|
transcodeType: TranscodeOptionsType,
|
||||||
|
@ -211,6 +220,8 @@ async function onNewWebTorrentFileResolution (
|
||||||
await retryTransactionWrapper(moveToNextState, video, payload.isNewVideo)
|
await retryTransactionWrapper(moveToNextState, video, payload.isNewVideo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
async function createHlsJobIfEnabled (user: MUserId, payload: {
|
async function createHlsJobIfEnabled (user: MUserId, payload: {
|
||||||
videoUUID: string
|
videoUUID: string
|
||||||
resolution: number
|
resolution: number
|
||||||
|
@ -241,16 +252,6 @@ async function createHlsJobIfEnabled (user: MUserId, payload: {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export {
|
|
||||||
processVideoTranscoding,
|
|
||||||
createHlsJobIfEnabled,
|
|
||||||
onNewWebTorrentFileResolution
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
async function createLowerResolutionsJobs (options: {
|
async function createLowerResolutionsJobs (options: {
|
||||||
video: MVideoFullLight
|
video: MVideoFullLight
|
||||||
user: MUserId
|
user: MUserId
|
||||||
|
|
|
@ -3,6 +3,8 @@ import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, IsInt, Mo
|
||||||
import { AttributesOnly } from '@shared/core-utils'
|
import { AttributesOnly } from '@shared/core-utils'
|
||||||
import { VideoModel } from './video'
|
import { VideoModel } from './video'
|
||||||
|
|
||||||
|
export type VideoJobInfoColumnType = 'pendingMove' | 'pendingTranscode'
|
||||||
|
|
||||||
@Table({
|
@Table({
|
||||||
tableName: 'videoJobInfo',
|
tableName: 'videoJobInfo',
|
||||||
indexes: [
|
indexes: [
|
||||||
|
@ -57,7 +59,7 @@ export class VideoJobInfoModel extends Model<Partial<AttributesOnly<VideoJobInfo
|
||||||
return VideoJobInfoModel.findOne({ where, transaction })
|
return VideoJobInfoModel.findOne({ where, transaction })
|
||||||
}
|
}
|
||||||
|
|
||||||
static async increaseOrCreate (videoUUID: string, column: 'pendingMove' | 'pendingTranscode'): Promise<number> {
|
static async increaseOrCreate (videoUUID: string, column: VideoJobInfoColumnType): Promise<number> {
|
||||||
const options = { type: QueryTypes.SELECT as QueryTypes.SELECT, bind: { videoUUID } }
|
const options = { type: QueryTypes.SELECT as QueryTypes.SELECT, bind: { videoUUID } }
|
||||||
|
|
||||||
const [ { pendingMove } ] = await VideoJobInfoModel.sequelize.query<{ pendingMove: number }>(`
|
const [ { pendingMove } ] = await VideoJobInfoModel.sequelize.query<{ pendingMove: number }>(`
|
||||||
|
@ -79,7 +81,7 @@ export class VideoJobInfoModel extends Model<Partial<AttributesOnly<VideoJobInfo
|
||||||
return pendingMove
|
return pendingMove
|
||||||
}
|
}
|
||||||
|
|
||||||
static async decrease (videoUUID: string, column: 'pendingMove' | 'pendingTranscode'): Promise<number> {
|
static async decrease (videoUUID: string, column: VideoJobInfoColumnType): Promise<number> {
|
||||||
const options = { type: QueryTypes.SELECT as QueryTypes.SELECT, bind: { videoUUID } }
|
const options = { type: QueryTypes.SELECT as QueryTypes.SELECT, bind: { videoUUID } }
|
||||||
|
|
||||||
const [ { pendingMove } ] = await VideoJobInfoModel.sequelize.query<{ pendingMove: number }>(`
|
const [ { pendingMove } ] = await VideoJobInfoModel.sequelize.query<{ pendingMove: number }>(`
|
||||||
|
|
Loading…
Reference in New Issue