PApostol opened a new issue #20384:
URL: https://github.com/apache/airflow/issues/20384
### Apache Airflow version
2.2.2 (latest released)
### What happened
After upgrading from Airflow 2.1.4 to 2.2.2, every DAG gives this error upon
execution:
> [2021-12-17, 15:01:12 UTC] {taskinstance.py:1259} INFO - Executing
<Task(_PythonDecoratedOperator): print_the_context> on 2021-12-17
15:01:08.943254+00:00
[2021-12-17, 15:01:12 UTC] {standard_task_runner.py:52} INFO - Started
process 873 to run task
[2021-12-17, 15:01:12 UTC] {standard_task_runner.py:76} INFO - Running:
['airflow', 'tasks', 'run', 'example_python_operator', 'print_the_context',
'manual__2021-12-17T15:01:08.943254+00:00', '--job-id', '326', '--raw',
'--subdir', 'DAGS_FOLDER/test.py', '--cfg-path', '/tmp/tmpej1imvkr',
'--error-file', '/tmp/tmpqn9ad7em']
[2021-12-17, 15:01:12 UTC] {standard_task_runner.py:77} INFO - Job 326:
Subtask print_the_context
[2021-12-17, 15:01:12 UTC] {standard_task_runner.py:92} ERROR - Failed to
execute job 326 for task print_the_context
Traceback (most recent call last):
File
"/home/ec2-user/venv/lib/python3.7/site-packages/airflow/task/task_runner/standard_task_runner.py",
line 85, in _start_by_fork
args.func(args, dag=self.dag)
File
"/home/ec2-user/venv/lib/python3.7/site-packages/airflow/cli/cli_parser.py",
line 48, in command
return func(*args, **kwargs)
File
"/home/ec2-user/venv/lib/python3.7/site-packages/airflow/utils/cli.py", line
92, in wrapper
return f(*args, **kwargs)
File
"/home/ec2-user/venv/lib/python3.7/site-packages/airflow/cli/commands/task_command.py",
line 287, in task_run
ti = _get_ti(task, args.execution_date_or_run_id)
File
"/home/ec2-user/venv/lib/python3.7/site-packages/airflow/utils/session.py",
line 70, in wrapper
return func(*args, session=session, **kwargs)
File
"/home/ec2-user/venv/lib/python3.7/site-packages/airflow/cli/commands/task_command.py",
line 86, in _get_ti
dag_run = _get_dag_run(task.dag, exec_date_or_run_id,
create_if_necssary, session)
File
"/home/ec2-user/venv/lib/python3.7/site-packages/airflow/cli/commands/task_command.py",
line 80, in _get_dag_run
) from None
airflow.exceptions.DagRunNotFound: DagRun for example_python_operator with
run_id or execution_date of 'manual__2021-12-17T15:01:08.943254+00:00' not found
Both tables `airflowdb.task_instance` and `airflowdb.dag_run` have rows with
`run_id` equal to "manual__2021-12-17T15:01:08.943254+00:00".
The issue seems to arise in the `_get_dag_run()` function from
[airflow/cli/commands/task_command.py](https://github.com/apache/airflow/blob/bb82cc0fbb7a6630eac1155d0c3b445dff13ceb6/airflow/cli/commands/task_command.py#L61-L72):
```
execution_date = None
with suppress(ParserError, TypeError):
execution_date = timezone.parse(exec_date_or_run_id)
if create_if_necessary and not execution_date:
return DagRun(dag_id=dag.dag_id, run_id=exec_date_or_run_id)
try:
return (
session.query(DagRun)
.filter(
DagRun.dag_id == dag.dag_id,
DagRun.execution_date == execution_date,
)
.one()
)
```
Here, `exec_date_or_run_id == 'manual__2021-12-17T15:01:08.943254+00:00'`
and `timezone.parse(exec_date_or_run_id)` fails, meaning `execution_date` stays
as `None` and the session query returns no results.
### What you expected to happen
Expect DAGs to run without the above error.
### How to reproduce
Upgraded from 2.1.4 to 2.2.2 and manually ran a few DAGs. The above log is
from the
[example_python_operator](https://github.com/apache/airflow/blob/main/airflow/example_dags/example_python_operator.py)
DAG provided on the Airflow repo.
### Operating System
Amazon Linux 2
### Versions of Apache Airflow Providers
_No response_
### Deployment
Virtualenv installation
### Deployment details
_No response_
### Anything else
Tried `airflow db upgrade` and `airflow db reset` without any luck. The
same issue appears on 2.2.3rc2.
Using MySQL 8.0.23.
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
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]