fix(backup): retry wont be scheduled if it is after the next scheduled backup
This commit is contained in:
parent
5d8c2925d8
commit
11bb95db92
1 changed files with 6 additions and 6 deletions
|
|
@ -225,15 +225,15 @@ export async function handleBackupFailure(
|
||||||
const currentRetryCount = schedule.failureRetryCount;
|
const currentRetryCount = schedule.failureRetryCount;
|
||||||
const maxRetries = schedule.maxRetries;
|
const maxRetries = schedule.maxRetries;
|
||||||
const shouldRetry = currentRetryCount < maxRetries;
|
const shouldRetry = currentRetryCount < maxRetries;
|
||||||
|
const nextRetryBackupAt = Date.now() + schedule.retryDelay;
|
||||||
|
const nextScheduledBackupAt = calculateNextRun(schedule.cronExpression);
|
||||||
|
|
||||||
if (shouldRetry) {
|
if (shouldRetry && nextRetryBackupAt < nextScheduledBackupAt) {
|
||||||
const nextBackupAt = Date.now() + schedule.retryDelay;
|
|
||||||
|
|
||||||
await scheduleQueries.updateStatus(scheduleId, organizationId, {
|
await scheduleQueries.updateStatus(scheduleId, organizationId, {
|
||||||
lastBackupAt: Date.now(),
|
lastBackupAt: Date.now(),
|
||||||
lastBackupStatus: "error",
|
lastBackupStatus: "error",
|
||||||
lastBackupError: errorDetails,
|
lastBackupError: errorDetails,
|
||||||
nextBackupAt,
|
nextBackupAt: nextRetryBackupAt,
|
||||||
failureRetryCount: currentRetryCount + 1,
|
failureRetryCount: currentRetryCount + 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -292,8 +292,8 @@ export async function handleBackupFailure(
|
||||||
scheduleName: schedule.name,
|
scheduleName: schedule.name,
|
||||||
error: `${errorDetails}\n\nFailed after ${maxRetries} retry attempts.`,
|
error: `${errorDetails}\n\nFailed after ${maxRetries} retry attempts.`,
|
||||||
})
|
})
|
||||||
.catch((notifError) => {
|
.catch((notifyError) => {
|
||||||
logger.error(`Failed to send backup failure notification: ${toMessage(notifError)}`);
|
logger.error(`Failed to send backup failure notification: ${toMessage(notifyError)}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue