GitHub user latent-9 added a comment to the discussion: 咨询:Airflow MySQL 2013 Lost connection 报错
A `(2013, 'Lost connection to MySQL server during query')` against the Airflow metadata database is almost always a pooled connection gone stale, not a network fault. MySQL closes idle connections after `wait_timeout`, but SQLAlchemy keeps them in its pool and can hand one back mid-query, which surfaces as 2013. The nightly-only timing fits this: connections sit idle through the quiet window, the server reaps them, and the batch then reuses a dead one. Two settings cover the common cases: ```ini [database] sql_alchemy_pool_pre_ping = True sql_alchemy_pool_recycle = 1800 ``` `pool_pre_ping` makes SQLAlchemy test a connection before use and reconnect transparently if it is dead. `pool_recycle` should be lower than MySQL's `wait_timeout` so connections refresh before the server drops them (check `SHOW VARIABLES LIKE 'wait_timeout'`). If it still shows up on large runs, raise MySQL's `max_allowed_packet`, since big serialized DAGs or XComs can exceed it and appear as a mid-query disconnect. `net_read_timeout` is worth a look too. Start with `pool_pre_ping`, which clears the majority of 2013 errors on the metadata DB. GitHub link: https://github.com/apache/airflow/discussions/71352#discussioncomment-17961330 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected]
