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

feat: Add query timeout support for MySql #10846

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

iliagrvch
Copy link

@iliagrvch iliagrvch commented Apr 23, 2024

Description of change

This feature adds the "enableQueryTimeout" option to MysqlConnectionOptions. When enabled, the value of "maxQueryExecutionTime" will be passed to the MySQL driver as the query timeout. (There is support for it by the MySQL driver: https://github.com/mysqljs/mysql?tab=readme-ov-file#timeouts)

Now, passing a value to "maxQueryExecutionTime" just logs queries that took more than the specified amount of time.

We use TypeORM with MySQL in multiple projects. Some of these projects involve direct interaction with users, and having a query timeout for the entire project connection is crucial to prevent server blocking due to long queries. On the other hand, some projects run in the background, and we don't mind queries taking a bit more time.

Since multiple drivers support query timeout configuration per datasource/connection (e.g., 'postgres'/'sqlserver'), and MySQL doesn't, I have decided to add this feature for MySQL as well.

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run format to apply prettier formatting
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change
  • The new commits follow conventions explained in [CONTRIBUTING.md]

This feature add "enableQueryTimeout" option to MysqlConnectionOptions, when enabled the value of "maxQueryExecutionTime" will be passed to mysql driver as query timeout.
@Elimorsson
Copy link

this will help a lot! I'm waiting for the merge of that PR

@michaelr231
Copy link

awesome! exactly what we need

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

3 participants