Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Task scheduler: mark task as active if we are scheduling ASAP (#16165)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Velten authored Aug 23, 2023
1 parent da162cb commit 873971a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/16165.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Task scheduler: mark task as active if we are scheduling as soon as possible.
2 changes: 1 addition & 1 deletion synapse/storage/databases/main/task_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def get_scheduled_tasks_txn(txn: LoggingTransaction) -> List[Dict[str, Any]]:
if clauses:
sql = sql + " WHERE " + " AND ".join(clauses)

sql = sql + "ORDER BY timestamp"
sql = sql + " ORDER BY timestamp"

txn.execute(sql, args)
return self.db_pool.cursor_to_dict(txn)
Expand Down
4 changes: 3 additions & 1 deletion synapse/util/task_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,15 @@ async def schedule_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():
timestamp = self._clock.time_msec()
status = TaskStatus.ACTIVE

task = ScheduledTask(
random_string(16),
action,
TaskStatus.SCHEDULED,
status,
timestamp,
resource_id,
params,
Expand Down

0 comments on commit 873971a

Please sign in to comment.