Skip to content

DAG-processor keeps on crashing due to MySql deadlock errors #60178

@msumit

Description

@msumit

Apache Airflow version

Other Airflow 3 version (please specify below)

If "Other Airflow 3 version" selected, which one?

3.0

What happened?

DAG processor keeps on crashing due to Mysql Deadlock errors.

File "/opt/airflow/venv/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query\n db.query(q)\n File "/opt/airflow/venv/lib/python3.11/site-packages/MySQLdb/connections.py", line 280, in query\n _mysql.connection.query(self, query)\nsqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1213, 'target: xxxxx.0.primary: vttablet: rpc error: code = Aborted desc = Deadlock found when trying to get lock; try restarting transaction (errno 1213) (sqlstate 40001) (CallerID: xxxxx-airflow-dag-processor): Sql: "delete from dag_schedule_asset_alias_reference where dag_schedule_asset_alias_reference.dag_id in (select dag.dag_id from dag where dag.is_stale = :dag_is_stale /* INT64 */)", BindVars: {#maxLimit: "type:INT64 value:\\"1000001\\""dag_is_stale: "type:INT64 valu')\n[SQL: DELETE FROM dag_schedule_asset_alias_reference WHERE dag_schedule_asset_alias_reference.dag_id IN (SELECT dag.dag_id \nFROM dag \nWHERE dag.is_stale = 1)]\n(Background on this error at: https://sqlalche.me/e/14/e3q8)

What you think should happen instead?

The DAG processor should not crash and process DAGs.

How to reproduce

Setup Airflow 3.0 through virtualenv and use a Mysql instance to run dag processor.

Operating System

Debian GNU/Linux 12 (bookworm)

Versions of Apache Airflow Providers

apache-airflow-providers-cncf-kubernetes 10.4.3
apache-airflow 3.0.0
apache-airflow-core 3.0.0
apache-airflow-ctl 0.0.1
apache-airflow-providers-common-compat 1.6.0
apache-airflow-providers-common-io 1.5.4
apache-airflow-providers-common-sql 1.26.0
apache-airflow-providers-fab 2.0.1
apache-airflow-providers-http 5.2.2
apache-airflow-providers-smtp 2.0.3
apache-airflow-providers-standard 1.0.0
apache-airflow-providers-uber 1.0.1
apache-airflow-task-sdk 1.0.0

Deployment

Virtualenv installation

Deployment details

No response

Anything else?

The stacktrace is from Airflow running against Vitess-Mysql, but we hit the same issue with normal Mysql 8 as well.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

area:Schedulerincluding HA (high availability) schedulerarea:corekind:bugThis is a clearly a bugneeds-triagelabel for new issues that we didn't triage yet

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions