Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve MariaDB's connection #4728

Merged
merged 2 commits into from May 19, 2024
Merged

Improve MariaDB's connection #4728

merged 2 commits into from May 19, 2024

Conversation

louislam
Copy link
Owner

@louislam louislam commented May 1, 2024

Knex sometimes throws Error: read ECONNRESET. Trying to improve this.

Reference:
knex/knex#3447 (comment)

@louislam
Copy link
Owner Author

louislam commented May 16, 2024

Actually, I don't know how to solve this issue. Setting the pool doesn't seem to be working.

The issue only happens when the database connection is idle for too long.

Setting propagateCreateError to false is a option, but the drawback is all db errors will be muted.

@CommanderStorm
Copy link
Collaborator

The issue only happens when the database connection is idle for too long

We could just create a no-op which is executed once every minute in a setInterval to keep the DB active, or am I missing something?

This issue should only happen for users who have not set up any monitors, right?

@louislam
Copy link
Owner Author

The issue only happens when the database connection is idle for too long

We could just create a no-op which is executed once every minute in a setInterval to keep the DB active, or am I missing something?

This issue should only happen for users who have not set up any monitors, right?

It can also affect MariaDB with custom timeout settings, also a very long interval monitor.

I just re-read the knex/knex#3447 (comment). It looks like I can override the validate function to prevent this.

@@ -209,14 +209,9 @@ class Database {
let config = {};

let mariadbPoolConfig = {
pool: {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it wrongly, that might be the reason why min: 0 was not working. Will test it again.

@louislam louislam marked this pull request as ready for review May 19, 2024 14:46
@louislam louislam merged commit 6bfb1be into master May 19, 2024
17 checks passed
@CommanderStorm CommanderStorm deleted the mariadb-improve-pool branch May 19, 2024 15:14
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.

None yet

2 participants