yuqian90 commented on pull request #18453:
URL: https://github.com/apache/airflow/pull/18453#issuecomment-977900512


   > > 
   > 
   > @yuqian90 How can I reproduce it? I tried with an empty SQLite DB and 
didn't get an error.
   > 
   > What versions of SQLite do you use?
   > 
   > ```
   > root@15dd880f441c:/opt/airflow# sqlite3 --version
   > 3.27.2 2019-02-25 16:06:06 
bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0alt1
   > ```
   
   Hi @kaxil, I have the exact same sqlite3 as you. Maybe it's not a problem 
with sqlite3. The error `has left an uncommitted transaction opened ` came from 
alembic. So potentially alembic or sqlalchemy is the problem here. These are 
the versions i have. Does any of these ring a bell?
   
   ```
   apache-airflow==2.2.2
   apache-airflow-providers-sqlite==2.0.1
   alembic==1.4.2
   Flask-SQLAlchemy==2.5.1
   marshmallow-sqlalchemy==0.26.1
   SQLAlchemy==1.3.19
   SQLAlchemy-JSONField==1.0.0
   SQLAlchemy-Utils==0.37.9
   ```
   
   Here's how to reproduce:
   - Create an empty directory to be used as `AIRFLOW_HOME`
   - Run airflow db init
   
   ```
   $ mkdir /tmp/test_airflow_home
   $ AIRFLOW_HOME=/tmp/test_airflow_home airflow db init
   DB: sqlite:////tmp/test_airflow_home/airflow.db
   [2021-11-24 08:51:16,278] {db.py:910} INFO - Creating tables
   INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
   INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
   WARNI [airflow.providers_manager] The package 
apache-airflow-providers-celery is not compatible with this version of Airflow. 
The package has version 1.0.1 but the minimum supported version of the package 
is 2.1.0
   WARNI [airflow.providers_manager] The package 
apache-airflow-providers-celery is not compatible with this version of Airflow. 
The package has version 1.0.1 but the minimum supported version of the package 
is 2.1.0
   INFO  [alembic.runtime.migration] Running upgrade  -> e3a246e0dc1, current 
schema
   INFO  [alembic.runtime.migration] Running upgrade e3a246e0dc1 -> 
1507a7289a2f, create is_encrypted
   /tmp/venv_airflow_2.2.2/lib/python3.8/site-packages/alembic/ddl/sqlite.py:40 
UserWarning: Skipping unsupported ALTER for creation of implicit 
constraintPlease refer to the batch mode feature which allows for SQLite 
migrations using a copy-and-move strategy.
   INFO  [alembic.runtime.migration] Running upgrade 1507a7289a2f -> 
13eb55f81627, maintain history for compatibility with earlier migrations
   INFO  [alembic.runtime.migration] Running upgrade 13eb55f81627 -> 
338e90f54d61, More logging into task_instance
   INFO  [alembic.runtime.migration] Running upgrade 338e90f54d61 -> 
52d714495f0, job_id indices
   INFO  [alembic.runtime.migration] Running upgrade 52d714495f0 -> 
502898887f84, Adding extra to Log
   INFO  [alembic.runtime.migration] Running upgrade 502898887f84 -> 
1b38cef5b76e, add dagrun
   INFO  [alembic.runtime.migration] Running upgrade 1b38cef5b76e -> 
2e541a1dcfed, task_duration
   INFO  [alembic.runtime.migration] Running upgrade 2e541a1dcfed -> 
40e67319e3a9, dagrun_config
   INFO  [alembic.runtime.migration] Running upgrade 40e67319e3a9 -> 
561833c1c74b, add password column to user
   INFO  [alembic.runtime.migration] Running upgrade 561833c1c74b -> 
4446e08588, dagrun start end
   INFO  [alembic.runtime.migration] Running upgrade 4446e08588 -> 
bbc73705a13e, Add notification_sent column to sla_miss
   INFO  [alembic.runtime.migration] Running upgrade bbc73705a13e -> 
bba5a7cfc896, Add a column to track the encryption state of the 'Extra' field 
in connection
   INFO  [alembic.runtime.migration] Running upgrade bba5a7cfc896 -> 
1968acfc09e3, add is_encrypted column to variable table
   INFO  [alembic.runtime.migration] Running upgrade 1968acfc09e3 -> 
2e82aab8ef20, rename user table
   INFO  [alembic.runtime.migration] Running upgrade 2e82aab8ef20 -> 
211e584da130, add TI state index
   INFO  [alembic.runtime.migration] Running upgrade 211e584da130 -> 
64de9cddf6c9, add task fails journal table
   INFO  [alembic.runtime.migration] Running upgrade 64de9cddf6c9 -> 
f2ca10b85618, add dag_stats table
   INFO  [alembic.runtime.migration] Running upgrade f2ca10b85618 -> 
4addfa1236f1, Add fractional seconds to mysql tables
   INFO  [alembic.runtime.migration] Running upgrade 4addfa1236f1 -> 
8504051e801b, xcom dag task indices
   INFO  [alembic.runtime.migration] Running upgrade 8504051e801b -> 
5e7d17757c7a, add pid field to TaskInstance
   INFO  [alembic.runtime.migration] Running upgrade 5e7d17757c7a -> 
127d2bf2dfa7, Add dag_id/state index on dag_run table
   INFO  [alembic.runtime.migration] Running upgrade 127d2bf2dfa7 -> 
cc1e65623dc7, add max tries column to task instance
   Traceback (most recent call last):
     File "/tmp/venv_airflow_2.2.2/bin/airflow", line 8, in <module>
       sys.exit(main())
     File 
"/tmp/venv_airflow_2.2.2/lib/python3.8/site-packages/airflow/__main__.py", line 
48, in main
       args.func(args)
     File 
"/tmp/venv_airflow_2.2.2/lib/python3.8/site-packages/airflow/cli/cli_parser.py",
 line 48, in command
       return func(*args, **kwargs)
     File 
"/tmp/venv_airflow_2.2.2/lib/python3.8/site-packages/airflow/cli/commands/db_command.py",
 line 31, in initdb
       db.initdb()
     File 
"/tmp/venv_airflow_2.2.2/lib/python3.8/site-packages/airflow/utils/session.py", 
line 70, in wrapper
       return func(*args, session=session, **kwargs)
     File 
"/tmp/venv_airflow_2.2.2/lib/python3.8/site-packages/airflow/utils/db.py", line 
592, in initdb
       upgradedb(session=session)
     File 
"/tmp/venv_airflow_2.2.2/lib/python3.8/site-packages/airflow/utils/session.py", 
line 67, in wrapper
       return func(*args, **kwargs)
     File 
"/tmp/venv_airflow_2.2.2/lib/python3.8/site-packages/airflow/utils/db.py", line 
911, in upgradedb
       command.upgrade(config, 'heads')
     File 
"/tmp/venv_airflow_2.2.2/lib/python3.8/site-packages/alembic/command.py", line 
298, in upgrade
       script.run_env()
     File 
"/tmp/venv_airflow_2.2.2/lib/python3.8/site-packages/alembic/script/base.py", 
line 489, in run_env
       util.load_python_file(self.dir, "env.py")
     File 
"/tmp/venv_airflow_2.2.2/lib/python3.8/site-packages/alembic/util/pyfiles.py", 
line 98, in load_python_file
       module = load_module_py(module_id, path)
     File 
"/tmp/venv_airflow_2.2.2/lib/python3.8/site-packages/alembic/util/compat.py", 
line 184, in load_module_py
       spec.loader.exec_module(module)
     File "<frozen importlib._bootstrap_external>", line 783, in exec_module
     File "<frozen importlib._bootstrap>", line 219, in 
_call_with_frames_removed
     File 
"/tmp/venv_airflow_2.2.2/lib/python3.8/site-packages/airflow/migrations/env.py",
 line 107, in <module>
       run_migrations_online()
     File 
"/tmp/venv_airflow_2.2.2/lib/python3.8/site-packages/airflow/migrations/env.py",
 line 101, in run_migrations_online
       context.run_migrations()
     File "<string>", line 8, in run_migrations
     File 
"/tmp/venv_airflow_2.2.2/lib/python3.8/site-packages/alembic/runtime/environment.py",
 line 846, in run_migrations
       self.get_context().run_migrations(**kw)
     File 
"/tmp/venv_airflow_2.2.2/lib/python3.8/site-packages/alembic/runtime/migration.py",
 line 542, in run_migrations
       raise util.CommandError(
   alembic.util.exc.CommandError: Migration "upgrade 127d2bf2dfa7 -> 
cc1e65623dc7, add max tries column to task instance" has left an uncommitted 
transaction opened; transactional_ddl is False so Alembic is not committing 
transactions
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to