Use saveInTransactionWithRetries helper
This commit is contained in:
parent
d1c64fd970
commit
c0b5a5eb4b
1 changed files with 5 additions and 21 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { throttle } from 'lodash'
|
import { throttle } from 'lodash'
|
||||||
import { retryTransactionWrapper, saveInTransactionWithRetries } from '@server/helpers/database-utils'
|
import { saveInTransactionWithRetries } from '@server/helpers/database-utils'
|
||||||
import { logger, loggerTagsFactory } from '@server/helpers/logger'
|
import { logger, loggerTagsFactory } from '@server/helpers/logger'
|
||||||
import { RUNNER_JOBS } from '@server/initializers/constants'
|
import { RUNNER_JOBS } from '@server/initializers/constants'
|
||||||
import { sequelizeTypescript } from '@server/initializers/database'
|
import { sequelizeTypescript } from '@server/initializers/database'
|
||||||
|
@ -124,11 +124,7 @@ export abstract class AbstractJobHandler <C, U extends RunnerJobUpdatePayload, S
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await retryTransactionWrapper(() => {
|
await saveInTransactionWithRetries(runnerJob)
|
||||||
return sequelizeTypescript.transaction(async transaction => {
|
|
||||||
return runnerJob.save({ transaction })
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -184,11 +180,7 @@ export abstract class AbstractJobHandler <C, U extends RunnerJobUpdatePayload, S
|
||||||
|
|
||||||
runnerJob.setToErrorOrCancel(cancelState)
|
runnerJob.setToErrorOrCancel(cancelState)
|
||||||
|
|
||||||
await retryTransactionWrapper(() => {
|
await saveInTransactionWithRetries(runnerJob)
|
||||||
return sequelizeTypescript.transaction(async transaction => {
|
|
||||||
await runnerJob.save({ transaction })
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
const children = await RunnerJobModel.listChildrenOf(runnerJob)
|
const children = await RunnerJobModel.listChildrenOf(runnerJob)
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
|
@ -219,11 +211,7 @@ export abstract class AbstractJobHandler <C, U extends RunnerJobUpdatePayload, S
|
||||||
|
|
||||||
runnerJob.resetToPending()
|
runnerJob.resetToPending()
|
||||||
|
|
||||||
await retryTransactionWrapper(() => {
|
await saveInTransactionWithRetries(runnerJob)
|
||||||
return sequelizeTypescript.transaction(async transaction => {
|
|
||||||
await runnerJob.save({ transaction })
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected setAbortState (runnerJob: MRunnerJob) {
|
protected setAbortState (runnerJob: MRunnerJob) {
|
||||||
|
@ -260,11 +248,7 @@ export abstract class AbstractJobHandler <C, U extends RunnerJobUpdatePayload, S
|
||||||
runnerJob.resetToPending()
|
runnerJob.resetToPending()
|
||||||
}
|
}
|
||||||
|
|
||||||
await retryTransactionWrapper(() => {
|
await saveInTransactionWithRetries(runnerJob)
|
||||||
return sequelizeTypescript.transaction(async transaction => {
|
|
||||||
await runnerJob.save({ transaction })
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
if (runnerJob.state === errorState) {
|
if (runnerJob.state === errorState) {
|
||||||
const children = await RunnerJobModel.listChildrenOf(runnerJob)
|
const children = await RunnerJobModel.listChildrenOf(runnerJob)
|
||||||
|
|
Loading…
Reference in a new issue