aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/runners/job-handlers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-05-19 15:20:12 +0200
committerChocobozzz <me@florianbigard.com>2023-05-19 15:20:12 +0200
commitc0b5a5eb4be94038ce4d44e03cd14e2f5a844868 (patch)
treee9a3513576af0c71ad83def91bb5361d0fddf6b9 /server/lib/runners/job-handlers
parentd1c64fd970fc236b9ba01ac944659051e9e04a99 (diff)
downloadPeerTube-c0b5a5eb4be94038ce4d44e03cd14e2f5a844868.tar.gz
PeerTube-c0b5a5eb4be94038ce4d44e03cd14e2f5a844868.tar.zst
PeerTube-c0b5a5eb4be94038ce4d44e03cd14e2f5a844868.zip
Use saveInTransactionWithRetries helper
Diffstat (limited to 'server/lib/runners/job-handlers')
-rw-r--r--server/lib/runners/job-handlers/abstract-job-handler.ts26
1 files changed, 5 insertions, 21 deletions
diff --git a/server/lib/runners/job-handlers/abstract-job-handler.ts b/server/lib/runners/job-handlers/abstract-job-handler.ts
index ca97d0881..329977de1 100644
--- a/server/lib/runners/job-handlers/abstract-job-handler.ts
+++ b/server/lib/runners/job-handlers/abstract-job-handler.ts
@@ -1,5 +1,5 @@
1import { throttle } from 'lodash' 1import { throttle } from 'lodash'
2import { retryTransactionWrapper, saveInTransactionWithRetries } from '@server/helpers/database-utils' 2import { saveInTransactionWithRetries } from '@server/helpers/database-utils'
3import { logger, loggerTagsFactory } from '@server/helpers/logger' 3import { logger, loggerTagsFactory } from '@server/helpers/logger'
4import { RUNNER_JOBS } from '@server/initializers/constants' 4import { RUNNER_JOBS } from '@server/initializers/constants'
5import { sequelizeTypescript } from '@server/initializers/database' 5import { sequelizeTypescript } from '@server/initializers/database'
@@ -124,11 +124,7 @@ export abstract class AbstractJobHandler <C, U extends RunnerJobUpdatePayload, S
124 return 124 return
125 } 125 }
126 126
127 await retryTransactionWrapper(() => { 127 await saveInTransactionWithRetries(runnerJob)
128 return sequelizeTypescript.transaction(async transaction => {
129 return runnerJob.save({ transaction })
130 })
131 })
132 } 128 }
133 129
134 // --------------------------------------------------------------------------- 130 // ---------------------------------------------------------------------------
@@ -184,11 +180,7 @@ export abstract class AbstractJobHandler <C, U extends RunnerJobUpdatePayload, S
184 180
185 runnerJob.setToErrorOrCancel(cancelState) 181 runnerJob.setToErrorOrCancel(cancelState)
186 182
187 await retryTransactionWrapper(() => { 183 await saveInTransactionWithRetries(runnerJob)
188 return sequelizeTypescript.transaction(async transaction => {
189 await runnerJob.save({ transaction })
190 })
191 })
192 184
193 const children = await RunnerJobModel.listChildrenOf(runnerJob) 185 const children = await RunnerJobModel.listChildrenOf(runnerJob)
194 for (const child of children) { 186 for (const child of children) {
@@ -219,11 +211,7 @@ export abstract class AbstractJobHandler <C, U extends RunnerJobUpdatePayload, S
219 211
220 runnerJob.resetToPending() 212 runnerJob.resetToPending()
221 213
222 await retryTransactionWrapper(() => { 214 await saveInTransactionWithRetries(runnerJob)
223 return sequelizeTypescript.transaction(async transaction => {
224 await runnerJob.save({ transaction })
225 })
226 })
227 } 215 }
228 216
229 protected setAbortState (runnerJob: MRunnerJob) { 217 protected setAbortState (runnerJob: MRunnerJob) {
@@ -260,11 +248,7 @@ export abstract class AbstractJobHandler <C, U extends RunnerJobUpdatePayload, S
260 runnerJob.resetToPending() 248 runnerJob.resetToPending()
261 } 249 }
262 250
263 await retryTransactionWrapper(() => { 251 await saveInTransactionWithRetries(runnerJob)
264 return sequelizeTypescript.transaction(async transaction => {
265 await runnerJob.save({ transaction })
266 })
267 })
268 252
269 if (runnerJob.state === errorState) { 253 if (runnerJob.state === errorState) {
270 const children = await RunnerJobModel.listChildrenOf(runnerJob) 254 const children = await RunnerJobModel.listChildrenOf(runnerJob)