FrankYang0529 commented on code in PR #72057:
URL: https://github.com/apache/airflow/pull/72057#discussion_r4172293172
##########
providers/edge3/src/airflow/providers/edge3/worker_api/routes/jobs.py:
##########
@@ -83,21 +92,32 @@ def fetch(
if not worker:
raise HTTPException(status.HTTP_404_NOT_FOUND, "Worker not found")
- query = (
- select(EdgeJobModel)
- .where(
- EdgeJobModel.state == TaskInstanceState.QUEUED,
- EdgeJobModel.concurrency_slots <= body.free_concurrency,
- )
- .order_by(EdgeJobModel.queued_dttm)
+ query = select(EdgeJobModel).where(
+ EdgeJobModel.state == TaskInstanceState.QUEUED,
+ EdgeJobModel.concurrency_slots <= body.free_concurrency,
)
if body.queues:
query = query.where(EdgeJobModel.queue.in_(body.queues))
if worker.team_name is not None:
query = query.where(EdgeJobModel.team_name == worker.team_name)
query = query.limit(1)
query = query.with_for_update(skip_locked=True)
- job: EdgeJobModel | None = session.scalar(query)
+
+ # Callbacks finish work that is already running, so a worker takes them
before any task, and
Review Comment:
Change the comment to mention that a single query would sort the whole
backlog, and that the callback query stays cheap because `dag_id` leads the
primary key.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]