Skip to content

Ensure proper cleanup of the database connection in createSchema#5315

Merged
HenryHengZJ merged 4 commits intoFlowiseAI:mainfrom
cuca24:main
Oct 28, 2025
Merged

Ensure proper cleanup of the database connection in createSchema#5315
HenryHengZJ merged 4 commits intoFlowiseAI:mainfrom
cuca24:main

Conversation

@cuca24
Copy link
Contributor

@cuca24 cuca24 commented Oct 11, 2025

fixes #4255
Potentially fixes the #4479

As per TypeORM documentation Disconnection (closing all connections in the pool) occurs when the destroy method is called.

All methods in MysqlRecordManager contains destroy call except createSchema call.

I tested locally and this keeps connection to 0 after the calls.

@HenryHengZJ
Copy link
Contributor

thanks! with this fix, have you tried testing again and see if that free up the ram?

@cuca24
Copy link
Contributor Author

cuca24 commented Oct 20, 2025

@HenryHengZJ
I tested both with this fix and without this fix. And i can confirm that this fix also fixes issue i reported in #4479

Without a fix memory consumption rises constantly, while with the fix, it always returns to the same memory usage after i run thousands api requests. I even run with 20 parallel processes at once and it seems to be working ok. Memory does rises a bit but it's not leaking (it's does not rise constantly) and after it finishes it returns to the memory consumption that was before making upsert api calls.

@HenryHengZJ
Copy link
Contributor

are you able to build and run it? because await this.getDataSource('createSchema') is throwing an error, getDataSource doesnt take in any input parameter

Refactor createSchema method to avoid duplicate dataSource retrieval.
Refactor createSchema to avoid redundant dataSource retrieval.
@cuca24
Copy link
Contributor Author

cuca24 commented Oct 21, 2025

@HenryHengZJ yes it should be const dataSource = await this.getDataSource(). without additional param. I used it for testing purposes but forgot to clean it out.

@HenryHengZJ HenryHengZJ merged commit 9554b1a into FlowiseAI:main Oct 28, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Record manager keeps open connections to mysql

2 participants