Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleared tasks get literal 'DagRunState.QUEUED' instead of the value 'queued' #17879

Closed
1 of 2 tasks
tothandor opened this issue Aug 28, 2021 · 7 comments · Fixed by #17886
Closed
1 of 2 tasks

Cleared tasks get literal 'DagRunState.QUEUED' instead of the value 'queued' #17879

tothandor opened this issue Aug 28, 2021 · 7 comments · Fixed by #17886
Labels
affected_version:2.1 Issues Reported for 2.1 area:core kind:bug This is a clearly a bug

Comments

@tothandor
Copy link

Apache Airflow version

2.1.3 (latest released)

Operating System

CentOS Stream release 8

Versions of Apache Airflow Providers

None of them are relevant

Deployment

Virtualenv installation

Deployment details

mkdir /srv/airflow
cd /srv/airflow
virtualenv venv
source venv/bin/activate
pip install apache-airflow==2.1.3
AIRFLOW_HOME and AIRFLOW_CONFIG is specified via environment variables in /etc/sysconfig/airflow, which is in turn used as EnvironmentFile in systemd service files.
systemctl start airflow-{scheduler,webserver,kerberos}
Python version: 3.9.2
LocalExecutors are used

What happened

On the Web UI, I had cleared failed tasks, which have been cleared properly, but the DagRun became black with a literal value of "DagRunState.QUEUED", therefore it can't be scheduled again.

What you expected to happen

DagRun state should be 'queued'.

How to reproduce

Just clear any tasks on the Web UI. I wonder how could it be that nobody noticed this issue.

Anything else

Here's a patch to fix it. Maybe the str method should be different, or the database/persistence layer should handle this, but for now, this solves the problem.

--- airflow/models/dag.py.orig  2021-08-28 09:48:05.465542450 +0200
+++ airflow/models/dag.py       2021-08-28 09:47:34.272639960 +0200
@@ -1153,7 +1153,7 @@
         confirm_prompt=False,
         include_subdags=True,
         include_parentdag=True,
-        dag_run_state: DagRunState = DagRunState.QUEUED,
+        dag_run_state: DagRunState = DagRunState.QUEUED.value,
         dry_run=False,
         session=None,
         get_tis=False,
@@ -1369,7 +1369,7 @@
         confirm_prompt=False,
         include_subdags=True,
         include_parentdag=False,
-        dag_run_state=DagRunState.QUEUED,
+        dag_run_state=DagRunState.QUEUED.value,
         dry_run=False,
     ):

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@tothandor tothandor added area:core kind:bug This is a clearly a bug labels Aug 28, 2021
@uranusjr
Copy link
Member

The proposed solution is wrong. The .value call should happen in Jinja templates or www/views.py (for presentation), not in models.

@tothandor
Copy link
Author

This has nothing to do with presentation. The appropriate value controls if a dagrun should be (re)executed or not.
The default value specified for clear() method's dag_run_state resulted a bad value.
See the contents of the dag_run table below.
image

@uranusjr
Copy link
Member

So the problem is we’re storing wrong values to the database? The change should be done at the boundary between the db and Pythron if that’s the case. Either we call .value when passing the value to SQLAlchemy, or we should change the state field to automatically do that when it receives an Enum.

@kaxil
Copy link
Member

kaxil commented Aug 28, 2021

I haven't been able to reproduce yet with Postgres & Python 3.8, what Metadata Database do you use Postgres, MySQL or SQLite? And which version

@kaxil kaxil added Can't Reproduce The problem cannot be reproduced and removed Can't Reproduce The problem cannot be reproduced labels Aug 28, 2021
@kaxil
Copy link
Member

kaxil commented Aug 28, 2021

If you are using MySQL with MySQLdb driver -- then you might see this error. I will have a patch ready in few mins

@kaxil
Copy link
Member

kaxil commented Aug 28, 2021

#17886 Should fix it -- can you try it with that change @tothandor please

kaxil added a commit to astronomer/airflow that referenced this issue Aug 28, 2021
same as apache#13278 but for `DagRunState` introduced in apache#16854

closes apache#17879
@eladkal eladkal added the affected_version:2.1 Issues Reported for 2.1 label Aug 30, 2021
@tothandor
Copy link
Author

It's working now. Thanks a lot! 🙏

kaxil added a commit that referenced this issue Aug 30, 2021
same as #13278 but for `DagRunState` introduced in #16854

closes #17879
kaxil added a commit that referenced this issue Sep 15, 2021
same as #13278 but for `DagRunState` introduced in #16854

closes #17879

(cherry picked from commit a3f9c69)
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Nov 27, 2021
same as apache/airflow#13278 but for `DagRunState` introduced in apache/airflow#16854

closes apache/airflow#17879

(cherry picked from commit a3f9c690aa80d12ff1d5c42eaaff4fced07b9429)

GitOrigin-RevId: 66dcbf429aee0316e206a1d6ded089580fc94ddf
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Mar 10, 2022
same as apache/airflow#13278 but for `DagRunState` introduced in apache/airflow#16854

closes apache/airflow#17879

GitOrigin-RevId: a3f9c690aa80d12ff1d5c42eaaff4fced07b9429
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Jun 4, 2022
same as apache/airflow#13278 but for `DagRunState` introduced in apache/airflow#16854

closes apache/airflow#17879

GitOrigin-RevId: a3f9c690aa80d12ff1d5c42eaaff4fced07b9429
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Jul 10, 2022
same as apache/airflow#13278 but for `DagRunState` introduced in apache/airflow#16854

closes apache/airflow#17879

GitOrigin-RevId: a3f9c690aa80d12ff1d5c42eaaff4fced07b9429
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Aug 27, 2022
same as apache/airflow#13278 but for `DagRunState` introduced in apache/airflow#16854

closes apache/airflow#17879

GitOrigin-RevId: a3f9c690aa80d12ff1d5c42eaaff4fced07b9429
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Oct 4, 2022
same as apache/airflow#13278 but for `DagRunState` introduced in apache/airflow#16854

closes apache/airflow#17879

GitOrigin-RevId: a3f9c690aa80d12ff1d5c42eaaff4fced07b9429
aglipska pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Oct 7, 2022
same as apache/airflow#13278 but for `DagRunState` introduced in apache/airflow#16854

closes apache/airflow#17879

GitOrigin-RevId: a3f9c690aa80d12ff1d5c42eaaff4fced07b9429
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Dec 7, 2022
same as apache/airflow#13278 but for `DagRunState` introduced in apache/airflow#16854

closes apache/airflow#17879

GitOrigin-RevId: a3f9c690aa80d12ff1d5c42eaaff4fced07b9429
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Jan 27, 2023
same as apache/airflow#13278 but for `DagRunState` introduced in apache/airflow#16854

closes apache/airflow#17879

GitOrigin-RevId: a3f9c690aa80d12ff1d5c42eaaff4fced07b9429
kosteev pushed a commit to kosteev/composer-airflow-test-copybara that referenced this issue Sep 12, 2024
same as apache/airflow#13278 but for `DagRunState` introduced in apache/airflow#16854

closes apache/airflow#17879

GitOrigin-RevId: a3f9c690aa80d12ff1d5c42eaaff4fced07b9429
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Sep 17, 2024
same as apache/airflow#13278 but for `DagRunState` introduced in apache/airflow#16854

closes apache/airflow#17879

GitOrigin-RevId: a3f9c690aa80d12ff1d5c42eaaff4fced07b9429
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Nov 7, 2024
same as apache/airflow#13278 but for `DagRunState` introduced in apache/airflow#16854

closes apache/airflow#17879

GitOrigin-RevId: a3f9c690aa80d12ff1d5c42eaaff4fced07b9429
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affected_version:2.1 Issues Reported for 2.1 area:core kind:bug This is a clearly a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants