Merge pull request #9722 from backstage/freben/tasks-janitor
backend-tasks: no unnecessary janitor log output on sqlite
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/backend-tasks': patch
|
||||
---
|
||||
|
||||
Only output janitor logs when actually timing out tasks
|
||||
@@ -62,19 +62,21 @@ export class PluginTaskSchedulerJanitor {
|
||||
|
||||
const dbNull = this.knex.raw('null');
|
||||
|
||||
const tasksQuery = this.knex<DbTasksRow>(DB_TASKS_TABLE)
|
||||
const tasks = await this.knex<DbTasksRow>(DB_TASKS_TABLE)
|
||||
.where('current_run_expires_at', '<', this.knex.fn.now())
|
||||
.update({
|
||||
current_run_ticket: dbNull,
|
||||
current_run_started_at: dbNull,
|
||||
current_run_expires_at: dbNull,
|
||||
});
|
||||
})
|
||||
.returning(['id']);
|
||||
|
||||
if (this.knex.client.config.client === 'sqlite3') {
|
||||
const tasks = await tasksQuery;
|
||||
this.logger.warn(`${tasks} tasks timed out and were lost`);
|
||||
// sqlite ignores "returning", returns number of rows changed instead
|
||||
if (typeof tasks === 'number') {
|
||||
if (tasks > 0) {
|
||||
this.logger.warn(`${tasks} tasks timed out and were lost`);
|
||||
}
|
||||
} else {
|
||||
const tasks = await tasksQuery.returning(['id']);
|
||||
for (const { id } of tasks) {
|
||||
this.logger.warn(`Task timed out and was lost: ${id}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user