You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/03/15 07:05:01 UTC
[GitHub] [airflow] ghostbody opened a new issue #22271: `TaskInstance.refresh_from_db` locked `DagRun` which is unexpected.
ghostbody opened a new issue #22271:
URL: https://github.com/apache/airflow/issues/22271
### Apache Airflow version
2.2.1
### What happened
Airflow reports `Mysql Error: Locked Wait Timeout`. And we take a look at the code which requires db lock and find this.


### What you think should happen instead
should we take this?
```python
if lock_for_update:
ti: Optional[TaskInstance] = with_row_locks(qry, of=cls).first()
```
Use `with_row_locks` in `utils` and make sure that the `of ` argument is included is better~
### How to reproduce
session A:
```python
from airflow.models.taskinstance import TaskInstance
from airflow.utils.session import create_session
session = create_session().__enter__()
ti = session.query(TaskInstance).first()
print(ti.dag_id) # get this dag_id as dag_id_x
ti.refresh_from_db(session=session, lock_for_update=True)
# And then hold this lock
```
session B
```python
from airflow.models.dagrun import DagRun
from airflow.utils.session import create_session
session = create_session().__enter__()
dag_run = session.query(DagRun).filter_by(dag_id='dag_id_x').with_for_update().first()
# this will hangs...
```
### Operating System
ubuntu 20.04
### Versions of Apache Airflow Providers
_No response_
### Deployment
Other Docker-based deployment
### Deployment details
_No response_
### Anything else
_No response_
### Are you willing to submit PR?
- [X] 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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] uranusjr commented on issue #22271: `TaskInstance.refresh_from_db` locked `DagRun` which is unexpected.
Posted by GitBox <gi...@apache.org>.
uranusjr commented on issue #22271:
URL: https://github.com/apache/airflow/issues/22271#issuecomment-1067684596
I don’t see how it’s unexpected, running a task instance requires some information on the DAG run containing it, and not locking the run would lead to potential inconsistencies.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org