Task scheduler: mark task as active if we are scheduling ASAP (#16165)

This commit is contained in:
Mathieu Velten 2023-08-23 13:37:51 +02:00 committed by GitHub
parent da162cbe4e
commit 873971a8b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

1
changelog.d/16165.misc Normal file
View File

@ -0,0 +1 @@
Task scheduler: mark task as active if we are scheduling as soon as possible.

View File

@ -92,7 +92,7 @@ class TaskSchedulerWorkerStore(SQLBaseStore):
if clauses: if clauses:
sql = sql + " WHERE " + " AND ".join(clauses) sql = sql + " WHERE " + " AND ".join(clauses)
sql = sql + "ORDER BY timestamp" sql = sql + " ORDER BY timestamp"
txn.execute(sql, args) txn.execute(sql, args)
return self.db_pool.cursor_to_dict(txn) return self.db_pool.cursor_to_dict(txn)

View File

@ -154,13 +154,15 @@ class TaskScheduler:
f"No function associated with action {action} of the scheduled task" f"No function associated with action {action} of the scheduled task"
) )
status = TaskStatus.SCHEDULED
if timestamp is None or timestamp < self._clock.time_msec(): if timestamp is None or timestamp < self._clock.time_msec():
timestamp = self._clock.time_msec() timestamp = self._clock.time_msec()
status = TaskStatus.ACTIVE
task = ScheduledTask( task = ScheduledTask(
random_string(16), random_string(16),
action, action,
TaskStatus.SCHEDULED, status,
timestamp, timestamp,
resource_id, resource_id,
params, params,