installing dify for the first time, there is no database table #17137

Closed
opened 2026-02-21 19:31:44 -05:00 by yindo · 0 comments
Owner

Originally created by @zhonglin6666 on GitHub (Sep 10, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.3.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

1. First helm install dify

2. kubectl get po

NAME                                 READY   STATUS      RESTARTS   AGE
dify-api-798bb6cdb9-46hvw            1/1     Running     1          26m
dify-init-db-data-vkwsf              0/3     Completed   12         26m
dify-plugin-daemon-d9dd686bd-jf9vs   1/1     Running     4          26m
dify-postgresql-0                    1/1     Running     0          26m
dify-proxy-7bdfcc5f5d-rtwh8          1/1     Running     0          26m
dify-redis-master-0                  1/1     Running     0          26m
dify-sandbox-7bf9fc548d-g7gnw        1/1     Running     0          26m
dify-web-644f75dc6-8gll4             1/1     Running     0          26m
dify-worker-897c95995-wpwwg          1/1     Running     0          26m
weaviate-0                           1/1     Running     0          26m

3. Query the database

only found dify plugin tables in postgresql, no dify-api tables
dify=# \d
                    List of relations
 Schema |             Name             | Type  |  Owner   
--------+------------------------------+-------+----------
 public | agent_strategy_installations | table | postgres
 public | ai_model_installations       | table | postgres
 public | endpoints                    | table | postgres
 public | install_tasks                | table | postgres
 public | plugin_declarations          | table | postgres
 public | plugin_installations         | table | postgres
 public | plugins                      | table | postgres
 public | serverless_runtimes          | table | postgres
 public | tenant_storages              | table | postgres
 public | tool_installations           | table | postgres
(10 rows)

4. logs dify-api

Running migrations
2025-09-11 02:37:45,180.180 INFO [MainThread] [utils.py:146] - Note: detected 112 virtual cores but NumExpr set to maximum of 64, check "NUMEXPR_MAX_THREADS" environment variable.
2025-09-11 02:37:45,181.181 INFO [MainThread] [utils.py:149] - Note: NumExpr detected 112 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 16.
2025-09-11 02:37:45,181.181 INFO [MainThread] [utils.py:162] - NumExpr defaulting to 16 threads.
2025-09-11 02:37:50,130.130 DEBUG [MainThread] [opendal_storage.py:38] - opendal operator created with scheme fs
2025-09-11 02:37:50,131.131 DEBUG [MainThread] [opendal_storage.py:41] - added retry layer to opendal operator
2025-09-11 02:37:50,131.131 INFO [MainThread] [repository_registry.py:38] - Registering WorkflowNodeExecution repository with RDBMS storage
2025-09-11 02:37:52,163.163 INFO [MainThread] [ext_otel_patch.py:63] - OpenTelemetry context.detach patched to handle None tokens
Preparing database migration...
Starting database migration.
ERROR [root] Failed to execute database migration
Traceback (most recent call last):
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__
    self._dbapi_connection = engine.raw_connection()
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3302, in raw_connection
    return self.pool.connect()
           ^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 449, in connect
    return _ConnectionFairy._checkout(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1263, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
          ^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 179, in _do_get
    with util.safe_reraise():
         ^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 177, in _do_get
    return self._create_connection()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 390, in _create_connection
    return _ConnectionRecord(self)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 643, in connect
    return dialect.connect(*cargs, **cparams)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 621, in connect
    return self.loaded_dbapi.connect(*cargs, **cparams)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/psycopg2/__init__.py", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/psycogreen/gevent.py", line 32, in gevent_wait_callback
    state = conn.poll()
            ^^^^^^^^^^^
psycopg2.OperationalError: Connection refused
	Is the server running on that host and accepting TCP/IP connections?


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/api/commands.py", line 671, in upgrade_db
    flask_migrate.upgrade()
  File "/app/api/.venv/lib/python3.12/site-packages/flask_migrate/__init__.py", line 111, in wrapped
    f(*args, **kwargs)
  File "/app/api/.venv/lib/python3.12/site-packages/flask_migrate/__init__.py", line 200, in upgrade
    command.upgrade(config, revision, sql=sql, tag=tag)
  File "/app/api/.venv/lib/python3.12/site-packages/alembic/command.py", line 408, in upgrade
    script.run_env()
  File "/app/api/.venv/lib/python3.12/site-packages/alembic/script/base.py", line 586, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/app/api/.venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
    module = load_module_py(module_id, path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 999, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/app/api/migrations/env.py", line 109, in <module>
    run_migrations_online()
  File "/app/api/migrations/env.py", line 93, in run_migrations_online
    with connectable.connect() as connection:
         ^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3278, in connect
    return self._connection_cls(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 148, in __init__
    Connection._handle_dbapi_exception_noconnection(
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2442, in _handle_dbapi_exception_noconnection
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__
    self._dbapi_connection = engine.raw_connection()
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3302, in raw_connection
    return self.pool.connect()
           ^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 449, in connect
    return _ConnectionFairy._checkout(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1263, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
          ^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 179, in _do_get
    with util.safe_reraise():
         ^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 177, in _do_get
    return self._create_connection()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 390, in _create_connection
    return _ConnectionRecord(self)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 643, in connect
    return dialect.connect(*cargs, **cparams)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 621, in connect
    return self.loaded_dbapi.connect(*cargs, **cparams)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/psycopg2/__init__.py", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/psycogreen/gevent.py", line 32, in gevent_wait_callback
    state = conn.poll()
            ^^^^^^^^^^^
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) Connection refused
	Is the server running on that host and accepting TCP/IP connections?

(Background on this error at: https://sqlalche.me/e/20/e3q8)
[2025-09-11 02:37:54 +0000] [1] [INFO] Starting gunicorn 23.0.0
[2025-09-11 02:37:54 +0000] [1] [INFO] Listening at: http://0.0.0.0:5001 (1)
[2025-09-11 02:37:54 +0000] [1] [INFO] Using worker: gevent
[2025-09-11 02:37:54 +0000] [99] [INFO] Booting worker with pid: 99
2025-09-11 02:37:57,946.946 INFO [MainThread] [utils.py:146] - Note: detected 112 virtual cores but NumExpr set to maximum of 64, check "NUMEXPR_MAX_THREADS" environment variable.
2025-09-11 02:37:57,947.947 INFO [MainThread] [utils.py:149] - Note: NumExpr detected 112 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 16.
2025-09-11 02:37:57,947.947 INFO [MainThread] [utils.py:162] - NumExpr defaulting to 16 threads.
2025-09-11 02:37:59,970.970 DEBUG [MainThread] [opendal_storage.py:38] - opendal operator created with scheme fs
2025-09-11 02:37:59,970.970 DEBUG [MainThread] [opendal_storage.py:41] - added retry layer to opendal operator
2025-09-11 02:37:59,970.970 INFO [MainThread] [repository_registry.py:38] - Registering WorkflowNodeExecution repository with RDBMS storage
2025-09-11 02:38:00,872.872 INFO [MainThread] [ext_otel_patch.py:63] - OpenTelemetry context.detach patched to handle None tokens

4. restart dify-api

 dify-api will work well, and upgrade db successful.

5. Try other three kubernetes environment

 First install normally, containers dify-api and dify-plugin tables.

Found:

If the physical machine environment is slow, there will be problems, and other physical machines that are not slow will run normally.

✔️ Expected Behavior

dify-api should be exited when failed upgrade db.

Actual Behavior

when physical machine environment is slow, dify-api failed to flask upgrade-db, and continue to run

Originally created by @zhonglin6666 on GitHub (Sep 10, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.3.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce # 1. First helm install dify # 2. kubectl get po ``` NAME READY STATUS RESTARTS AGE dify-api-798bb6cdb9-46hvw 1/1 Running 1 26m dify-init-db-data-vkwsf 0/3 Completed 12 26m dify-plugin-daemon-d9dd686bd-jf9vs 1/1 Running 4 26m dify-postgresql-0 1/1 Running 0 26m dify-proxy-7bdfcc5f5d-rtwh8 1/1 Running 0 26m dify-redis-master-0 1/1 Running 0 26m dify-sandbox-7bf9fc548d-g7gnw 1/1 Running 0 26m dify-web-644f75dc6-8gll4 1/1 Running 0 26m dify-worker-897c95995-wpwwg 1/1 Running 0 26m weaviate-0 1/1 Running 0 26m ``` # 3. Query the database only found dify plugin tables in postgresql, no dify-api tables ``` dify=# \d List of relations Schema | Name | Type | Owner --------+------------------------------+-------+---------- public | agent_strategy_installations | table | postgres public | ai_model_installations | table | postgres public | endpoints | table | postgres public | install_tasks | table | postgres public | plugin_declarations | table | postgres public | plugin_installations | table | postgres public | plugins | table | postgres public | serverless_runtimes | table | postgres public | tenant_storages | table | postgres public | tool_installations | table | postgres (10 rows) ``` # 4. logs dify-api ``` Running migrations 2025-09-11 02:37:45,180.180 INFO [MainThread] [utils.py:146] - Note: detected 112 virtual cores but NumExpr set to maximum of 64, check "NUMEXPR_MAX_THREADS" environment variable. 2025-09-11 02:37:45,181.181 INFO [MainThread] [utils.py:149] - Note: NumExpr detected 112 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 16. 2025-09-11 02:37:45,181.181 INFO [MainThread] [utils.py:162] - NumExpr defaulting to 16 threads. 2025-09-11 02:37:50,130.130 DEBUG [MainThread] [opendal_storage.py:38] - opendal operator created with scheme fs 2025-09-11 02:37:50,131.131 DEBUG [MainThread] [opendal_storage.py:41] - added retry layer to opendal operator 2025-09-11 02:37:50,131.131 INFO [MainThread] [repository_registry.py:38] - Registering WorkflowNodeExecution repository with RDBMS storage 2025-09-11 02:37:52,163.163 INFO [MainThread] [ext_otel_patch.py:63] - OpenTelemetry context.detach patched to handle None tokens Preparing database migration... Starting database migration. ERROR [root] Failed to execute database migration Traceback (most recent call last): File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ self._dbapi_connection = engine.raw_connection() ^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3302, in raw_connection return self.pool.connect() ^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 449, in connect return _ConnectionFairy._checkout(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1263, in _checkout fairy = _ConnectionRecord.checkout(pool) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout rec = pool._do_get() ^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 179, in _do_get with util.safe_reraise(): ^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__ raise exc_value.with_traceback(exc_tb) File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 177, in _do_get return self._create_connection() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 390, in _create_connection return _ConnectionRecord(self) ^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ self.__connect() File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect with util.safe_reraise(): ^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__ raise exc_value.with_traceback(exc_tb) File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect self.dbapi_connection = connection = pool._invoke_creator(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 643, in connect return dialect.connect(*cargs, **cparams) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 621, in connect return self.loaded_dbapi.connect(*cargs, **cparams) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/psycopg2/__init__.py", line 122, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/psycogreen/gevent.py", line 32, in gevent_wait_callback state = conn.poll() ^^^^^^^^^^^ psycopg2.OperationalError: Connection refused Is the server running on that host and accepting TCP/IP connections? The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/api/commands.py", line 671, in upgrade_db flask_migrate.upgrade() File "/app/api/.venv/lib/python3.12/site-packages/flask_migrate/__init__.py", line 111, in wrapped f(*args, **kwargs) File "/app/api/.venv/lib/python3.12/site-packages/flask_migrate/__init__.py", line 200, in upgrade command.upgrade(config, revision, sql=sql, tag=tag) File "/app/api/.venv/lib/python3.12/site-packages/alembic/command.py", line 408, in upgrade script.run_env() File "/app/api/.venv/lib/python3.12/site-packages/alembic/script/base.py", line 586, in run_env util.load_python_file(self.dir, "env.py") File "/app/api/.venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file module = load_module_py(module_id, path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py spec.loader.exec_module(module) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap_external>", line 999, in exec_module File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed File "/app/api/migrations/env.py", line 109, in <module> run_migrations_online() File "/app/api/migrations/env.py", line 93, in run_migrations_online with connectable.connect() as connection: ^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3278, in connect return self._connection_cls(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 148, in __init__ Connection._handle_dbapi_exception_noconnection( File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2442, in _handle_dbapi_exception_noconnection raise sqlalchemy_exception.with_traceback(exc_info[2]) from e File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ self._dbapi_connection = engine.raw_connection() ^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3302, in raw_connection return self.pool.connect() ^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 449, in connect return _ConnectionFairy._checkout(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1263, in _checkout fairy = _ConnectionRecord.checkout(pool) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout rec = pool._do_get() ^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 179, in _do_get with util.safe_reraise(): ^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__ raise exc_value.with_traceback(exc_tb) File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 177, in _do_get return self._create_connection() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 390, in _create_connection return _ConnectionRecord(self) ^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ self.__connect() File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect with util.safe_reraise(): ^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__ raise exc_value.with_traceback(exc_tb) File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect self.dbapi_connection = connection = pool._invoke_creator(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 643, in connect return dialect.connect(*cargs, **cparams) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 621, in connect return self.loaded_dbapi.connect(*cargs, **cparams) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/psycopg2/__init__.py", line 122, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/psycogreen/gevent.py", line 32, in gevent_wait_callback state = conn.poll() ^^^^^^^^^^^ sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) Connection refused Is the server running on that host and accepting TCP/IP connections? (Background on this error at: https://sqlalche.me/e/20/e3q8) [2025-09-11 02:37:54 +0000] [1] [INFO] Starting gunicorn 23.0.0 [2025-09-11 02:37:54 +0000] [1] [INFO] Listening at: http://0.0.0.0:5001 (1) [2025-09-11 02:37:54 +0000] [1] [INFO] Using worker: gevent [2025-09-11 02:37:54 +0000] [99] [INFO] Booting worker with pid: 99 2025-09-11 02:37:57,946.946 INFO [MainThread] [utils.py:146] - Note: detected 112 virtual cores but NumExpr set to maximum of 64, check "NUMEXPR_MAX_THREADS" environment variable. 2025-09-11 02:37:57,947.947 INFO [MainThread] [utils.py:149] - Note: NumExpr detected 112 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 16. 2025-09-11 02:37:57,947.947 INFO [MainThread] [utils.py:162] - NumExpr defaulting to 16 threads. 2025-09-11 02:37:59,970.970 DEBUG [MainThread] [opendal_storage.py:38] - opendal operator created with scheme fs 2025-09-11 02:37:59,970.970 DEBUG [MainThread] [opendal_storage.py:41] - added retry layer to opendal operator 2025-09-11 02:37:59,970.970 INFO [MainThread] [repository_registry.py:38] - Registering WorkflowNodeExecution repository with RDBMS storage 2025-09-11 02:38:00,872.872 INFO [MainThread] [ext_otel_patch.py:63] - OpenTelemetry context.detach patched to handle None tokens ``` # 4. restart dify-api dify-api will work well, and upgrade db successful. # 5. Try other three kubernetes environment First install normally, containers dify-api and dify-plugin tables. # Found: If the physical machine environment is slow, there will be problems, and other physical machines that are not slow will run normally. ### ✔️ Expected Behavior dify-api should be exited when failed upgrade db. ### ❌ Actual Behavior when physical machine environment is slow, dify-api failed to flask upgrade-db, and continue to run
yindo added the 🐞 bugoutdated labels 2026-02-21 19:31:44 -05:00
yindo closed this issue 2026-02-21 19:31:44 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#17137