airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (AIRFLOW-3001) Accumulative tis slow allocation of new schedule
Date Tue, 04 Sep 2018 08:54:00 GMT


ASF GitHub Bot commented on AIRFLOW-3001:

ubermen closed pull request #3840: [AIRFLOW-3001] Add task_instance table index 'ti_dag_date'

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/airflow/migrations/versions/ b/airflow/migrations/versions/
index 6c63d0a9dd..22624a4c8d 100644
--- a/airflow/migrations/versions/
+++ b/airflow/migrations/versions/
@@ -7,9 +7,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
@@ -176,6 +176,12 @@ def upgrade():
             ['dag_id', 'state'],
+        op.create_index(
+            'ti_dag_date',
+            'task_instance',
+            ['dag_id', 'execution_date'],
+            unique=False
+        )
@@ -269,6 +275,7 @@ def downgrade():
     op.drop_index('ti_state_lkp', table_name='task_instance')
     op.drop_index('ti_pool', table_name='task_instance')
     op.drop_index('ti_dag_state', table_name='task_instance')
+    op.drop_index('ti_dag_date', table_name='task_instance')
diff --git a/airflow/ b/airflow/
index 2096785b41..c41f2a9dbe 100755
--- a/airflow/
+++ b/airflow/
@@ -880,6 +880,7 @@ class TaskInstance(Base, LoggingMixin):
     __table_args__ = (
         Index('ti_dag_state', dag_id, state),
+        Index('ti_dag_date', dag_id, execution_date),
         Index('ti_state', state),
         Index('ti_state_lkp', dag_id, task_id, execution_date, state),
         Index('ti_pool', pool, state, priority_weight),


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

> Accumulative tis slow allocation of new schedule
> ------------------------------------------------
>                 Key: AIRFLOW-3001
>                 URL:
>             Project: Apache Airflow
>          Issue Type: Improvement
>          Components: scheduler
>    Affects Versions: 1.10.0
>            Reporter: Jason Kim
>            Assignee: Jason Kim
>            Priority: Major
> I have created very long term schedule in short interval. (2~3 years as 10 min interval)
> So, dag could be bigger and bigger as scheduling goes on.
> Finally, at critical point (I don't know exactly when it is), the allocation of new task_instances
get slow and then almost stop.
> I found that in this point, many slow query logs had occurred. (I was using mysql as
meta repository)
> queries like this
> "SELECT * FROM task_instance WHERE dag_id = 'some_dag_id' AND execution_date = ''2018-09-01
> I could resolve this issue by adding new index consists of dag_id and execution_date.
> So, I wanted 1.10 branch to be modified to create task_instance table with the index.
> Thanks.

This message was sent by Atlassian JIRA

View raw message