Skip to content

DB connection leak #5580

@yangxikun

Description

@yangxikun

Bug Description

DB connection pool overflow:
企业微信截图_2acb957e-0ede-41e3-a0cb-82ea911f03ae

Reproduction

  1. Create simple flow
Clipboard_Screenshot_1736305727
  1. curl call api: api/v1/build/47b14ff4-f165-44c5-af90-d6a742ff7f6f/flow
curl --location 'http://localhost:3000/api/v1/build/47b14ff4-f165-44c5-af90-d6a742ff7f6f/flow' \
--header 'x-api-key: sk-xxx-xxx' \
--header 'Content-Type: application/json' \
--data '{
    "inputs": {
        "input_value": "hello",
        "session": "xxx"
    }
}'

Expected behavior

Release unused db connection.

Who can help?

@ogabrielluiz

Operating System

mac

Langflow Version

v1.1.1

Python Version

3.12

Screenshot

Every curl will leak a db connection:

Clipboard_Screenshot_1736306030

I debugged and found the problem is in build_flow->event_generator:
Clipboard_Screenshot_1736306163

If not data, build_graph_and_get_order will run by asyncio.create_task, this will cause AsyncDbSession doesn't close.

If run build_graph_and_get_order directly with await, AsyncDbSession close correctly.

Flow File

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions