Skip to content

Creating a backfill via Airflow API results in internal server error if SQLite is used #66726

Closed

Description

@Prometheus3375

Under which category would you file this issue?

Airflow Core

Apache Airflow version

3.2.1

Steps to reproduce

  1. Create Dockerfile with the contents below:
FROM apache/airflow:slim-3.2.1-python3.12

ENV AIRFLOW_HOME=/opt/airflow
ENV PYTHONUTF8=1
ENV PYTHONPATH=/opt/airflow

USER airflow

EXPOSE 8080

ENTRYPOINT ["bash", "-c", "airflow db migrate && exec airflow standalone"]
  1. Create directory dags with test.py as follows:
from datetime import timedelta
from typing import Unpack

from airflow import DAG
from airflow.sdk import Context, task_group
from airflow.sdk.definitions.decorators import task

with DAG(
    dag_id="test_dag",
    schedule=timedelta(days=1),
) as dag:
    @task
    def test_task1(**context: Unpack[Context]) -> list[dict[str, int]]:
        return [{'other': 1}, {'other': 2}, {'other': 3}]

    @task_group
    def test_group(data: int, other: int) -> None:

        @task
        def t1(data: int, other: int, **context: Unpack[Context]) -> list[int]:
            return [data, other]

        t1(data, other)

    g = test_group.partial(data=2).expand_kwargs(test_task1())
  1. Build image from the dockerfile: docker build -t test-airflow ..
  2. Run container: docker run --name airflow-test -p 8080:8080 -v ./dags:/opt/airflow/dags -d test-airflow. Note: on Windows use -v .\dags:/opt/airflow/dags instead.
  3. In the container logs get the password for user admin.
  4. Once Airflow is started, open any API client.
  5. Get auth token:
POST http://localhost:8080/auth/token
{
  "username": "admin",
  "password": "password from logs"
}
  1. Create backfill for test_dag. Do not forget to add Bearer Token to headers:
POST http://localhost:8080/api/v2/backfills
{
  "dag_id": "test_dag",
  "from_date": "2025-03-01",
  "to_date": "2025-04-01",
  "run_backwards": false,
  "dag_run_conf": {},
  "reprocess_behavior": "none",
  "max_active_runs": 3
}

Expected result

Request from step 8 returns JSON with the info about created backfill.

Actual result

Request from step 8 returns HTTP status code 500 (Internal Server Error).
However, backfill is successfully created as per GET http://localhost:8080/api/v2/backfills?dag_id=test_dag

Container logs about the error:

api-server | 2026-05-11T17:31:18.318524Z [info     ] creating dag run               [airflow.serialization.definitions.dag] loc=dag.py:526 logical_date=DateTime(2025, 3, 1, 0, 0, 0, tzinfo=Timezone('UTC')) partition_key=None run_after=DateTime(2025, 3, 1, 0, 0, 0, tzinfo=Timezone('UTC')) run_id=backfill__2025-03-01T00:00:00+00:00
api-server | 2026-05-11T17:31:18.419695Z [info     ] Created backfill Dag run.      [airflow.models.backfill] backfill_id=1 dag_id=test_dag info=DagRunInfo(run_after=DateTime(2025, 3, 1, 0, 0, 0, tzinfo=Timezone('UTC')), data_interval=DataInterval(start=DateTime(2025, 3, 1, 0, 0, 0, tzinfo=Timezone('UTC')), end=DateTime(2025, 3, 1, 0, 0, 0, tzinfo=Timezone('UTC'))), partition_date=None, partition_key=None) loc=backfill.py:690
api-server | 2026-05-11T17:31:18.421520Z [info     ] creating dag run               [airflow.serialization.definitions.dag] loc=dag.py:526 logical_date=DateTime(2025, 3, 2, 0, 0, 0, tzinfo=Timezone('UTC')) partition_key=None run_after=DateTime(2025, 3, 2, 0, 0, 0, tzinfo=Timezone('UTC')) run_id=backfill__2025-03-02T00:00:00+00:00
api-server | 2026-05-11T17:31:18.497663Z [info     ] Created backfill Dag run.      [airflow.models.backfill] backfill_id=1 dag_id=test_dag info=DagRunInfo(run_after=DateTime(2025, 3, 2, 0, 0, 0, tzinfo=Timezone('UTC')), data_interval=DataInterval(start=DateTime(2025, 3, 2, 0, 0, 0, tzinfo=Timezone('UTC')), end=DateTime(2025, 3, 2, 0, 0, 0, tzinfo=Timezone('UTC'))), partition_date=None, partition_key=None) loc=backfill.py:690
api-server | 2026-05-11T17:31:18.499467Z [info     ] creating dag run               [airflow.serialization.definitions.dag] loc=dag.py:526 logical_date=DateTime(2025, 3, 3, 0, 0, 0, tzinfo=Timezone('UTC')) partition_key=None run_after=DateTime(2025, 3, 3, 0, 0, 0, tzinfo=Timezone('UTC')) run_id=backfill__2025-03-03T00:00:00+00:00
api-server | 2026-05-11T17:31:18.661214Z [info     ] Created backfill Dag run.      [airflow.models.backfill] backfill_id=1 dag_id=test_dag info=DagRunInfo(run_after=DateTime(2025, 3, 3, 0, 0, 0, tzinfo=Timezone('UTC')), data_interval=DataInterval(start=DateTime(2025, 3, 3, 0, 0, 0, tzinfo=Timezone('UTC')), end=DateTime(2025, 3, 3, 0, 0, 0, tzinfo=Timezone('UTC'))), partition_date=None, partition_key=None) loc=backfill.py:690
api-server | 2026-05-11T17:31:18.663197Z [info     ] creating dag run               [airflow.serialization.definitions.dag] loc=dag.py:526 logical_date=DateTime(2025, 3, 4, 0, 0, 0, tzinfo=Timezone('UTC')) partition_key=None run_after=DateTime(2025, 3, 4, 0, 0, 0, tzinfo=Timezone('UTC')) run_id=backfill__2025-03-04T00:00:00+00:00
api-server | 2026-05-11T17:31:19.260954Z [info     ] Created backfill Dag run.      [airflow.models.backfill] backfill_id=1 dag_id=test_dag info=DagRunInfo(run_after=DateTime(2025, 3, 4, 0, 0, 0, tzinfo=Timezone('UTC')), data_interval=DataInterval(start=DateTime(2025, 3, 4, 0, 0, 0, tzinfo=Timezone('UTC')), end=DateTime(2025, 3, 4, 0, 0, 0, tzinfo=Timezone('UTC'))), partition_date=None, partition_key=None) loc=backfill.py:690
api-server | 2026-05-11T17:31:19.262727Z [info     ] creating dag run               [airflow.serialization.definitions.dag] loc=dag.py:526 logical_date=DateTime(2025, 3, 5, 0, 0, 0, tzinfo=Timezone('UTC')) partition_key=None run_after=DateTime(2025, 3, 5, 0, 0, 0, tzinfo=Timezone('UTC')) run_id=backfill__2025-03-05T00:00:00+00:00
api-server | 2026-05-11T17:31:19.962730Z [info     ] Created backfill Dag run.      [airflow.models.backfill] backfill_id=1 dag_id=test_dag info=DagRunInfo(run_after=DateTime(2025, 3, 5, 0, 0, 0, tzinfo=Timezone('UTC')), data_interval=DataInterval(start=DateTime(2025, 3, 5, 0, 0, 0, tzinfo=Timezone('UTC')), end=DateTime(2025, 3, 5, 0, 0, 0, tzinfo=Timezone('UTC'))), partition_date=None, partition_key=None) loc=backfill.py:690
api-server | 2026-05-11T17:31:19.964579Z [info     ] creating dag run               [airflow.serialization.definitions.dag] loc=dag.py:526 logical_date=DateTime(2025, 3, 6, 0, 0, 0, tzinfo=Timezone('UTC')) partition_key=None run_after=DateTime(2025, 3, 6, 0, 0, 0, tzinfo=Timezone('UTC')) run_id=backfill__2025-03-06T00:00:00+00:00
api-server | 2026-05-11T17:31:20.098439Z [info     ] Created backfill Dag run.      [airflow.models.backfill] backfill_id=1 dag_id=test_dag info=DagRunInfo(run_after=DateTime(2025, 3, 6, 0, 0, 0, tzinfo=Timezone('UTC')), data_interval=DataInterval(start=DateTime(2025, 3, 6, 0, 0, 0, tzinfo=Timezone('UTC')), end=DateTime(2025, 3, 6, 0, 0, 0, tzinfo=Timezone('UTC'))), partition_date=None, partition_key=None) loc=backfill.py:690
api-server | 2026-05-11T17:31:20.100228Z [info     ] creating dag run               [airflow.serialization.definitions.dag] loc=dag.py:526 logical_date=DateTime(2025, 3, 7, 0, 0, 0, tzinfo=Timezone('UTC')) partition_key=None run_after=DateTime(2025, 3, 7, 0, 0, 0, tzinfo=Timezone('UTC')) run_id=backfill__2025-03-07T00:00:00+00:00
api-server | 2026-05-11T17:31:20.238051Z [info     ] Created backfill Dag run.      [airflow.models.backfill] backfill_id=1 dag_id=test_dag info=DagRunInfo(run_after=DateTime(2025, 3, 7, 0, 0, 0, tzinfo=Timezone('UTC')), data_interval=DataInterval(start=DateTime(2025, 3, 7, 0, 0, 0, tzinfo=Timezone('UTC')), end=DateTime(2025, 3, 7, 0, 0, 0, tzinfo=Timezone('UTC'))), partition_date=None, partition_key=None) loc=backfill.py:690
api-server | 2026-05-11T17:31:20.239764Z [info     ] creating dag run               [airflow.serialization.definitions.dag] loc=dag.py:526 logical_date=DateTime(2025, 3, 8, 0, 0, 0, tzinfo=Timezone('UTC')) partition_key=None run_after=DateTime(2025, 3, 8, 0, 0, 0, tzinfo=Timezone('UTC')) run_id=backfill__2025-03-08T00:00:00+00:00
api-server | 2026-05-11T17:31:20.311646Z [info     ] Created backfill Dag run.      [airflow.models.backfill] backfill_id=1 dag_id=test_dag info=DagRunInfo(run_after=DateTime(2025, 3, 8, 0, 0, 0, tzinfo=Timezone('UTC')), data_interval=DataInterval(start=DateTime(2025, 3, 8, 0, 0, 0, tzinfo=Timezone('UTC')), end=DateTime(2025, 3, 8, 0, 0, 0, tzinfo=Timezone('UTC'))), partition_date=None, partition_key=None) loc=backfill.py:690
api-server | 2026-05-11T17:31:20.313395Z [info     ] creating dag run               [airflow.serialization.definitions.dag] loc=dag.py:526 logical_date=DateTime(2025, 3, 9, 0, 0, 0, tzinfo=Timezone('UTC')) partition_key=None run_after=DateTime(2025, 3, 9, 0, 0, 0, tzinfo=Timezone('UTC')) run_id=backfill__2025-03-09T00:00:00+00:00
api-server | 2026-05-11T17:31:20.318924Z [info     ] request finished               [http.access] client_addr=172.17.0.1:37540 duration_us=2576580 loc=http_access_log.py:98 method=POST path=/api/v2/backfills query= status_code=500
api-server | 2026-05-11T17:31:20.319456Z [error    ] Exception in ASGI application
api-server | [uvicorn.error] loc=httptools_impl.py:425
api-server | Traceback (most recent call last):
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
api-server | self.dialect.do_execute(
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 952, in do_execute
api-server | cursor.execute(statement, parameters)
api-server | sqlite3.OperationalError: database is locked
api-server | The above exception was the direct cause of the following exception:
api-server | Traceback (most recent call last):
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/uvicorn/protocols/http/httptools_impl.py", line 420, in run_asgi
api-server | result = await app(  # type: ignore[func-returns-value]
api-server | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/fastapi/applications.py", line 1159, in __call__
api-server | await super().__call__(scope, receive, send)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/applications.py", line 107, in __call__
api-server | await self.middleware_stack(scope, receive, send)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 186, in __call__
api-server | raise exc
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 164, in __call__
api-server | await self.app(scope, receive, _send)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/airflow/api_fastapi/common/http_access_log.py", line 83, in __call__
api-server | await self.app(scope, receive, capture_send)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/gzip.py", line 29, in __call__
api-server | await responder(scope, receive, send)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/gzip.py", line 130, in __call__
api-server | await super().__call__(scope, receive, send)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/gzip.py", line 46, in __call__
api-server | await self.app(scope, receive, self.send_with_compression)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/base.py", line 191, in __call__
api-server | with recv_stream, send_stream, collapse_excgroups():
api-server | ^^^^^^^^^^^^^^^^^^^^
api-server | File "/usr/python/lib/python3.12/contextlib.py", line 158, in __exit__
api-server | self.gen.throw(value)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/_utils.py", line 87, in collapse_excgroups
api-server | raise exc
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/base.py", line 193, in __call__
api-server | response = await self.dispatch_func(request, call_next)
api-server | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/airflow/api_fastapi/auth/middlewares/refresh_token.py", line 61, in dispatch
api-server | response = await call_next(request)
api-server | ^^^^^^^^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/base.py", line 168, in call_next
api-server | raise app_exc from app_exc.__cause__ or app_exc.__context__
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/base.py", line 144, in coro
api-server | await self.app(scope, receive_or_disconnect, send_no_error)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 63, in __call__
api-server | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
api-server | raise exc
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
api-server | await app(scope, receive, sender)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
api-server | await self.app(scope, receive, send)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/routing.py", line 716, in __call__
api-server | await self.middleware_stack(scope, receive, send)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/routing.py", line 736, in app
api-server | await route.handle(scope, receive, send)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/routing.py", line 290, in handle
api-server | await self.app(scope, receive, send)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/fastapi/routing.py", line 134, in app
api-server | await wrap_app_handling_exceptions(app, request)(scope, receive, send)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
api-server | raise exc
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
api-server | await app(scope, receive, sender)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/fastapi/routing.py", line 120, in app
api-server | response = await f(request)
api-server | ^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/fastapi/routing.py", line 674, in app
api-server | raw_response = await run_endpoint_function(
api-server | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/fastapi/routing.py", line 330, in run_endpoint_function
api-server | return await run_in_threadpool(dependant.call, **values)
api-server | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/starlette/concurrency.py", line 32, in run_in_threadpool
api-server | return await anyio.to_thread.run_sync(func)
api-server | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/anyio/to_thread.py", line 63, in run_sync
api-server | return await get_async_backend().run_sync_in_worker_thread(
api-server | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 2518, in run_sync_in_worker_thread
api-server | return await future
api-server | ^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 1002, in run
api-server | result = context.run(func, *args)
api-server | ^^^^^^^^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/airflow/api_fastapi/core_api/routes/public/backfills.py", line 233, in create_backfill
api-server | backfill_obj = _create_backfill(
api-server | ^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/airflow/models/backfill.py", line 627, in _create_backfill
api-server | _create_runs_non_partitioned(
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/airflow/models/backfill.py", line 679, in _create_runs_non_partitioned
api-server | _create_backfill_dag_run_non_partitioned(
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/airflow/models/backfill.py", line 377, in _create_backfill_dag_run_non_partitioned
api-server | dr = dag.create_dagrun(
api-server | ^^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/airflow/utils/session.py", line 98, in wrapper
api-server | return func(*args, **kwargs)
api-server | ^^^^^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/airflow/serialization/definitions/dag.py", line 572, in create_dagrun
api-server | orm_dagrun = _create_orm_dagrun(
api-server | ^^^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/airflow/utils/session.py", line 98, in wrapper
api-server | return func(*args, **kwargs)
api-server | ^^^^^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/airflow/serialization/definitions/dag.py", line 1196, in _create_orm_dagrun
api-server | session.flush()
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 4331, in flush
api-server | self._flush(objects)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 4466, in _flush
api-server | with util.safe_reraise():
api-server | ^^^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 121, in __exit__
api-server | raise exc_value.with_traceback(exc_tb)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 4427, in _flush
api-server | flush_context.execute()
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/orm/unitofwork.py", line 466, in execute
api-server | rec.execute(self)
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/orm/unitofwork.py", line 642, in execute
api-server | util.preloaded.orm_persistence.save_obj(
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/orm/persistence.py", line 93, in save_obj
api-server | _emit_insert_statements(
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/orm/persistence.py", line 1233, in _emit_insert_statements
api-server | result = connection.execute(
api-server | ^^^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1419, in execute
api-server | return meth(
api-server | ^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/elements.py", line 527, in _execute_on_connection
api-server | return connection._execute_clauseelement(
api-server | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1641, in _execute_clauseelement
api-server | ret = self._execute_context(
api-server | ^^^^^^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1846, in _execute_context
api-server | return self._exec_single_context(
api-server | ^^^^^^^^^^^^^^^^^^^^^^^^^^
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1986, in _exec_single_context
api-server | self._handle_dbapi_exception(
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2363, in _handle_dbapi_exception
api-server | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
api-server | self.dialect.do_execute(
api-server | File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 952, in do_execute
api-server | cursor.execute(statement, parameters)
api-server | sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
api-server | [SQL: INSERT INTO dag_run (dag_id, queued_at, logical_date, start_date, end_date, state, run_id, creating_job_id, run_type, triggered_by, triggering_user_name, conf, data_interval_start, data_interval_end, run_after, last_scheduling_decision, log_template_id, created_at, updated_at, clear_number, backfill_id, bundle_version, scheduled_by_job_id, context_carrier, created_dag_version_id, partition_key, partition_date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, span_status]
api-server | [parameters: ('test_dag', '2026-05-11 17:31:20.315260', '2025-03-09 00:00:00.000000', None, None, <DagRunState.QUEUED: 'queued'>, 'backfill__2025-03-09T00:00:00+00:00', None, <DagRunType.BACKFILL_JOB: 'backfill'>, 'BACKFILL', 'admin', '{}', '2025-03-09 00:00:00.000000', '2025-03-09 00:00:00.000000', '2025-03-09 00:00:00.000000', None, 2, '2026-05-11 17:31:20.316700', '2026-05-11 17:31:20.316707', 0, 1, None, None, '{"__var": {"traceparent": "00-50eac562494f9c159f72cbe7bba1e998-f2fd18493b34ae19-01"}, "__type": "dict"}', '019e1814a7a5788fbd9faf5352fc16cb', None, None)]
api-server | (Background on this error at: https://sqlalche.me/e/20/e3q8)

Basically, API just fails to return the JSON to the user.

Operating System

Windows 10

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. added
    kind:bug
    needs-triage
    on May 11, 2026
  2. boring-cyborg commented on May 11, 2026

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

  3. added
    area:API
    area:backfill
    on May 11, 2026
  4. kir-rin commented on May 22, 2026

    @kir-rin
    Contributor

    Thanks for the detailed report!

    My suspicion is that this is a SQLite locking issue under concurrent access.
    In airflow standalone, multiple processes (scheduler, api-server, triggerer, etc.) access the same SQLite database.
    When creating a backfill via API, the database is locked error occurs because SQLite doesn't handle concurrent writes well, even with WAL mode.

    Notably, is_lock_not_available_error() only recognizes PostgreSQL/MySQL lock errors, not SQLite's SQLITE_BUSY.

    Since airflow standalone and SQLite are development-only, one could argue this is expected behavior under concurrent load.

  5. Prometheus3375 commented on May 22, 2026

    @Prometheus3375
    Author

    because SQLite doesn't handle concurrent writes well, even with WAL mode

    Are there concurrent write operations when creating a backfill through API? I've got the impression that the API just fails to read db to retrieve newly created backfill. If this is the case, then it might be worth trying to run PRAGMA journal_mode=WAL; when SQLite is created to address the issue. However, if there are concurrent write operations, then nothing can be done on the db level indeed.

  6. eladkal commented on May 26, 2026

    @eladkal
    Contributor

    Since airflow standalone and SQLite are development-only, one could argue this is expected behavior under concurrent load.

    Returning internal error is not an expected behavior. If the feature isn't supported on SqlLite by design then we should catch this case and rase informative error explaining the user that to use the feature they need to change to PostgresSQL/MySql

  7. 10 remaining items

  8. pierrejeambrun commented on Jun 24, 2026

    @pierrejeambrun
    Member

    I'm not able to reproduce the bug with the mentioned steps.

    Is there anything more needed for this to show? Can you give more context please.

  9. pierrejeambrun commented on Jun 24, 2026

    @pierrejeambrun
    Member

    Same Dockerfile, same Dag -> backfill request is succeeding

    Image
  10. Prometheus3375 commented on Jun 24, 2026

    @Prometheus3375
    Author

    I will recheck later this week, but here is the the result of docker version. My OS is Windows 10.

    Client:
     Cloud integration: v1.0.35+desktop.5
     Version:           24.0.6
     API version:       1.43
     Go version:        go1.20.7
     Git commit:        ed223bc
     Built:             Mon Sep  4 12:32:48 2023
     OS/Arch:           windows/amd64
     Context:           default
    
    Server: Docker Desktop 4.24.2 (124339)
     Engine:
      Version:          24.0.6
      API version:      1.43 (minimum version 1.12)
      Go version:       go1.20.7
      Git commit:       1a79695
      Built:            Mon Sep  4 12:32:16 2023
      OS/Arch:          linux/amd64
      Experimental:     false
     containerd:
      Version:          1.6.22
      GitCommit:        8165feabfdfe38c65b599c4993d227328c231fca
     runc:
      Version:          1.1.8
      GitCommit:        v1.1.8-0-g82f18fe
     docker-init:
      Version:          0.19.0
      GitCommit:        de40ad0
    
  11. pierrejeambrun commented on Jun 25, 2026

    @pierrejeambrun
    Member

    I'm using latest main, just so you know.

  12. lohitkolluri commented on Jun 28, 2026

    @lohitkolluri
    Contributor

    Hi, did you get a chance to investigate this? Could you let me know if you're still able to reproduce the issue?

  13. Prometheus3375 commented on Jun 28, 2026

    @Prometheus3375
    Author

    I am still getting the error.

    2026-06-28.20-34-34-8mb.mp4
  14. Prometheus3375 commented on Jun 28, 2026

    @Prometheus3375
    Author

    It can be something Windows specific or Docker Engine specific. On what system you are trying to reproduce?

  15. lohitkolluri commented on Jun 28, 2026

    @lohitkolluri
    Contributor

    Reproduced the exact database is locked → HTTP 500 from this issue on macOS (not Windows-specific). The race surfaces under concurrent backfill creation — a single sequential request succeeds because PRAGMA busy_timeout=5000 masks the contention. The Backfill row is committed before the DagRun inserts, so a 500 leaves an orphan backfill with zero DagRuns (the silent corruption the issue reports).

    Important

    Reproducer is below. 20 parallel POST /api/v2/backfills against airflow standalone + SQLite + this issue's exact DAG. The first request returns HTTP 500; the rest return 409.


    Environment

    Component Value
    Host OS macOS 27.0 (Darwin 27.0.0, arm64)
    Docker Docker Desktop 29.5.2 (build 79eb04c), LinuxKit 6.12.76
    Arch aarch64 (Apple Silicon), 4 CPUs / 3.827 GiB
    Image apache/airflow:slim-3.2.1-python3.12 (sha256:4172ec40…)
    Components airflow standalone (api-server, scheduler, dag-processor, triggerer)
    DB SQLite at /opt/airflow/airflow.db
    PRAGMA busy_timeout 5000 ms (SQLAlchemy default)

    Reproduction

    The issue's Dockerfile and dags/test.py are followed verbatim. The trigger is concurrent requests rather than a single one.

    # Get auth token
    TOKEN=$(curl -s -X POST http://localhost:8080/auth/token \
        -H "Content-Type: application/json" \
        -d '{"username":"admin","password":"<PASSWORD>"}' \
        | python3 -c "import json,sys;print(json.load(sys.stdin)['access_token'])")
    
    # Fire 20 concurrent backfill requests
    for i in {1..20}; do
      (curl -s -w "REQ_${i}: HTTP %{http_code}\n" --max-time 30 \
          -X POST http://localhost:8080/api/v2/backfills \
          -H "Authorization: Bearer $TOKEN" \
          -H "Content-Type: application/json" \
          -d '{
            "dag_id": "test_dag",
            "from_date": "2025-03-01",
            "to_date":   "2025-04-01",
            "run_backwards": false,
            "dag_run_conf": {},
            "reprocess_behavior": "none",
            "max_active_runs": 3
          }' -o /dev/null) &
      sleep 0.05
    done
    wait

    Tip

    Why a single request doesn't trigger it on macOS/Linux:
    PRAGMA busy_timeout=5000 lets the long backfill INSERT absorb the dag-processor's writes without raising. Under concurrent API writes the lock window is too long for busy_timeout to absorb, and the next flush gets SQLITE_BUSY.
    On Windows, SQLite uses mandatory file locks (LockFileEx) so even one contending write during the long INSERT fails fast — that's why the single-request case the original reporter saw is reproducible on Windows but not on POSIX.

    Results

    Run Concurrency Stagger Outcome
    1 20 parallel POST /backfills 50 ms REQ_1 → HTTP 500, REQ_2..20 → 409
    2 30 parallel POST /backfills 20 ms REQ_1 → HTTP 500, REQ_2..30 → 409

    Outcome: 2/2 runs reproduced the 500. It consistently lands on the first request to acquire the write lock; the remaining requests short-circuit on the AlreadyRunningBackfill check.


    Captured error trace

    Full ASGI traceback (verbatim from docker logs)
    api-server | 2026-06-28T17:54:46.473431Z [info     ] request finished  [http.access] client_addr=192.168.65.1:63515 duration_us=70994 loc=http_access_log.py:98 method=POST path=/api/v2/backfills query= status_code=500
    api-server | 2026-06-28T17:54:46.473947Z [error    ] Exception in ASGI application
    api-server | [uvicorn.error] loc=httptools_impl.py:425
    api-server | Traceback (most recent call last):
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
    api-server |     self.dialect.do_execute(
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 952, in do_execute
    api-server |     cursor.execute(statement, parameters)
    api-server | sqlite3.OperationalError: database is locked
    api-server | The above exception was the direct cause of the following exception:
    api-server | Traceback (most recent call last):
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/uvicorn/protocols/http/httptools_impl.py", line 420, in run_asgi
    api-server |     result = await app(  # type: ignore[func-returns-value]
    api-server |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/fastapi/applications.py", line 1159, in __call__
    api-server |     await super().__call__(scope, receive, send)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/applications.py", line 107, in __call__
    api-server |     await self.app(scope, receive, send)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 186, in __call__
    api-server |     raise exc
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 164, in __call__
    api-server |     await self.app(scope, receive, _send)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/airflow/api_fastapi/common/http_access_log.py", line 83, in __call__
    api-server |     await self.app(scope, receive, capture_send)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/gzip.py", line 29, in __call__
    api-server |     await responder(scope, receive, send)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/gzip.py", line 130, in __call__
    api-server |     await super().__call__(scope, receive, send)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/gzip.py", line 46, in __call__
    api-server |     await self.app(scope, receive, self.send_with_compression)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/base.py", line 191, in __call__
    api-server |     with recv_stream, send_stream, collapse_excgroups():
    api-server |                          ^^^^^^^^^^^^^^^^^^^^
    api-server |   File "/usr/python/lib/python3.12/contextlib.py", line 158, in __exit__
    api-server |     self.gen.throw(value)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/_utils.py", line 87, in collapse_excgroups
    api-server |     raise exc
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/base.py", line 193, in __call__
    api-server |     response = await self.dispatch_func(request, call_next)
    api-server |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/airflow/api_fastapi/auth/middlewares/refresh_token.py", line 61, in dispatch
    api-server |     response = await call_next(request)
    api-server |                       ^^^^^^^^^^^^^^^^^^^^
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/base.py", line 168, in call_next
    api-server |     raise app_exc from app_exc.__cause__ or app_exc.__context__
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/base.py", line 144, in coro
    api-server |     await self.app(scope, receive_or_disconnect, send_no_error)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 63, in __call__
    api-server |     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    api-server |     raise exc
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    api-server |     await app(scope, receive, sender)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    api-server |     await self.app(scope, receive, send)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/routing.py", line 716, in __call__
    api-server |     await self.middleware_stack(scope, receive, send)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/middleware/base.py", line 736, in app
    api-server |     await route.handle(scope, receive, send)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/routing.py", line 290, in handle
    api-server |     await self.app(scope, receive, send)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    api-server |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
    api-server |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    api-server |     raise exc
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    api-server |     await app(scope, receive, sender)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    api-server |     await self.app(scope, receive, send)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/routing.py", line 716, in __call__
    api-server |     await self.middleware_stack(scope, receive, send)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/routing.py", line 736, in app
    api-server |     await route.handle(scope, receive, send)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/routing.py", line 290, in handle
    api-server |     await self.app(scope, receive, send)
    api-server |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    api-server |     raise exc
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    api-server |     await app(scope, receive, sender)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/fastapi/routing.py", line 120, in app
    api-server |     response = await f(request)
    api-server |                ^^^^^^^^^^^^^^^^
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/fastapi/routing.py", line 674, in app
    api-server |     raw_response = await run_endpoint_function(
    api-server |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/fastapi/routing.py", line 330, in run_endpoint_function
    api-server |     return await run_in_threadpool(dependant.call, **values)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/starlette/concurrency.py", line 32, in run_in_threadpool
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/anyio/to_thread.py", line 63, in run_sync
    api-server |     return await get_async_backend().run_sync_in_worker_thread(
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 2518, in run_sync_in_worker_thread
    api-server |     return await future
    api-server |                       ^^^^^^^^^^^^
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 1002, in run
    api-server |     result = context.run(func, *args, **kwargs)
    api-server |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/airflow/api_fastapi/core_api/routes/public/backfills.py", line 233, in create_backfill
    api-server |     backfill_obj = _create_backfill(
    api-server |                   ^^^^^^^^^^^^^^^^^
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/airflow/models/backfill.py", line 627, in _create_backfill
    api-server |     _create_runs_non_partitioned(
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/airflow/models/backfill.py", line 679, in _create_runs_non_partitioned
    api-server |     _create_backfill_dag_run_non_partitioned(
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/airflow/models/backfill.py", line 377, in _create_backfill_dag_run_non_partitioned
    api-server |     dr = dag.create_dagrun(
    api-server |         ^^^^^^^^^^^^^^^^^^
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/airflow/utils/session.py", line 98, in wrapper
    api-server |     return func(*args, **kwargs)
    api-server |            ^^^^^^^^^^^^^^^^^^^^^
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/airflow/serialization/definitions/dag.py", line 572, in create_dagrun
    api-server |     orm_dagrun = _create_orm_dagrun(
    api-server |                   ^^^^^^^^^^^^^^^^^^^
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/airflow/utils/session.py", line 98, in wrapper
    api-server |     return func(*args, **kwargs)
    api-server |            ^^^^^^^^^^^^^^^^^^^^^
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/airflow/serialization/definitions/dag.py", line 1196, in _create_orm_dagrun
    api-server |     session.flush()
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 4331, in flush
    api-server |     self._flush(objects)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 4466, in _flush
    api-server |     with util.safe_reraise():
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 121, in __exit__
    api-server |     raise exc_value.with_traceback(exc_tb)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 4427, in _flush
    api-server |     flush_context.execute()
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/orm/unitofwork.py", line 466, in execute
    api-server |     rec.execute(self)
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/orm/unitofwork.py", line 642, in execute
    api-server |     util.preloaded.orm_persistence.save_obj(
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/orm/persistence.py", line 93, in save_obj
    api-server |     _emit_insert_statements(
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/orm/persistence.py", line 1233, in _emit_insert_statements
    api-server |     result = connection.execute(
    api-server |                ^^^^^^^^^^^^^^^^^^^
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1419, in execute
    api-server |     return meth(
    api-server |            ^^^^^
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/sql/elements.py", line 527, in _execute_on_connection
    api-server |     return connection._execute_clauseelement(
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1641, in _execute_clauseelement
    api-server |     ret = self._execute_context(
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1846, in _execute_context
    api-server |     return self._exec_single_context(
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1986, in _exec_single_context
    api-server |     self._handle_dbapi_exception(
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2363, in _handle_dbapi_exception
    api-server |     raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
    api-server |     self.dialect.do_execute(
    api-server |   File "/home/airflow/.local/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 952, in do_execute
    api-server |     cursor.execute(statement, parameters)
    api-server | sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
    api-server | [SQL: INSERT INTO backfill_dag_run (backfill_id, dag_run_id, exception_reason, logical_date, partition_key, sort_ordinal) VALUES (?, ?, ?, ?, ?, ?)]
    api-server | [parameters: (2, None, <BackfillDagRunExceptionReason.ALREADY_EXISTS: 'already exists'>, '2025-03-03 00:00:00.000000', None, 3)]
    api-server | (Background on this error at: https://sqlalche.me/e/20/e3q8)
    

    Match against the original issue's traceback: same call chain (airflow/models/backfill.py:627 → 679 → 377 → dag.create_dagrun → _create_orm_dagrun → session.flush()), same exception class (sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked), same INSERT INTO … SQL family. The only divergence is which insert fails first — backfill_dag_run in this run, dag_run in the original — both are inside the same _create_runs_non_partitioned loop.


    The silent corruption (the second half of this issue)

    After the 500, the API returns an error but the Backfill row persists. A retry returns 409 Conflict: There is already a running backfill for this dag — yet no DagRun was ever scheduled. The backfill looks done in GET /api/v2/backfills, but it's an orphan.

    $ docker exec airflow-test sqlite3 /opt/airflow/airflow.db \
        "SELECT id, dag_id, from_date, to_date, completed_at FROM backfill ORDER BY id;"
    1|test_dag|2025-03-01 00:00:00.000000|2025-04-01 00:00:00.000000|2026-06-28 17:54:16.365333
    2|test_dag|2025-03-01 00:00:00.000000|2025-04-01 00:00:00.000000|2026-06-28 17:54:59.401456
    
    $ docker exec airflow-test sqlite3 /opt/airflow/airflow.db \
        "SELECT COUNT(*) FROM backfill_dag_run WHERE backfill_id=2;"
    2
    
    $ docker exec airflow-test sqlite3 /opt/airflow/airflow.db \
        "SELECT COUNT(*) FROM dag_run WHERE backfill_id=2;"
    0
    

    Warning

    Backfill id=2 has completed_at set but 0 dag_run rows. This matches the issue's "backfill is successfully created as per GET" observation. The 500 is not transient from the user's perspective — the backfill appears complete in the API and cancel / pause are the only recovery path.


    Root cause

    session.flush() inside _create_orm_dagrun sends SQL to the DB but stays inside the same transaction. The backfill INSERT loop holds the SQLite write lock for the duration of the operation, releasing it only when the outer create_backfill route commits (or rolls back). When the dag-processor, scheduler, or another API writer wins the race first, the API's next flush receives SQLITE_BUSY and OperationalError propagates to the client as HTTP 500.

    Note

    Platform difference is a property of SQLite's file-locking model, not the bug itself:

    • Windows — mandatory file locks (LockFileEx); any contending write fails fast. The single-request case the original reporter observed is the natural consequence.
    • macOS / Linux — advisory file locks; SQLITE_BUSY only surfaces under heavier concurrent load. PRAGMA busy_timeout=5000 masks it for a single sequential request, which explains why maintainers could not reproduce with one call.
  16. lohitkolluri commented on Jun 29, 2026

    @lohitkolluri
    Contributor

    @pierrejeambrun Did you get a chance to review the video shared by Prometheus3375 and diagnostic report i shared?

  17. pierrejeambrun commented on Jul 1, 2026

    @pierrejeambrun
    Member

    Yes I was able to reproduce, thanks. Reviewed the linked PR.

  18. removed
    needs-triage
    on Jul 1, 2026
  19. added this to the Airflow 3.3.1 milestone on Jul 1, 2026
  20. bujjibabukatta commented on Jul 7, 2026

    @bujjibabukatta
    Contributor

    SQLite doesn't support row-level locking, so with_row_locks() was crashing with database is locked when creating a backfill. Fixed by returning the query early when the dialect is SQLite. Added a test to cover this case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:APIarea:backfillarea:coregood first issuekind:bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions