apache / apache/airflow

Add option to disable “SELECT GET_LOCK('airflow_MIGRATIONS', 1800)“ when exec airflow db migrate

Open
#56,949 1 comment 0 reactions 0 assignees View on GitHub
area:db-migrations kind:feature needs-triage
Dominant language
Python
Stars
46.9k
Forks
17.8k
Avg merge
2d 10h
Merged PRs (30d)
483

Description

### Description

Add option to disable “SELECT GET_LOCK('airflow_MIGRATIONS', 1800)“ when exec airflow db migrate

### Use case/motivation

I deploy airflow to cloud using cloud mysql. When I exec db migrate, it throws `sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1105, "slice: slice-0 execution timed out, sql: SELECT GET_LOCK('airflow_MIGRATIONS', 1800)")` while my local mysql works well.
I delete the source code at airflow.utils.db.py:1364 `conn.execute(text("SELECT GET_LOCK(:id, :timeout)"), {"id": str(lock), "timeout": lock_timeout})` and airflow.utils.db.py:1379 `conn.execute(text("select RELEASE_LOCK(:id)"), {"id": str(lock)})` and exec db migrate at cloud server, all problems solved.
So, if there is a possibility that airflow could add an option using to disable sql lock check in airflow.cfg

### Related issues

_No response_

### Are you willing to submit a 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)

Contributor guide

Open the contributing guide

Research direction

Start with airflow/utils/db.py around the named GET_LOCK and RELEASE_LOCK calls, then inspect how airflow db migrate reads configuration from airflow.cfg. Verify the option against the reported cloud MySQL failure; done means migrations can skip those lock queries when disabled while the current behavior remains available.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, python, sqlalchemy
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.