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

Add new error class StatementTimeout which will be raised when statement timeout exceeded #31129

Merged
merged 1 commit into from
Nov 13, 2017

Conversation

kamipo
Copy link
Member

@kamipo kamipo commented Nov 11, 2017

We are sometimes using The MAX_EXECUTION_TIME hint for MySQL depending
on the situation. It will prevent catastrophic performance down by wrong
performing queries.

The new error class StatementTimeout will make to be easier to handle
that case.

https://dev.mysql.com/doc/refman/5.7/en/optimizer-hints.html#optimizer-hints-execution-time

…ement timeout exceeded

We are sometimes using The MAX_EXECUTION_TIME hint for MySQL depending
on the situation. It will prevent catastrophic performance down by wrong
performing queries.

The new error class `StatementTimeout` will make to be easier to handle
that case.

https://dev.mysql.com/doc/refman/5.7/en/optimizer-hints.html#optimizer-hints-execution-time
@kamipo kamipo merged commit a968a76 into rails:master Nov 13, 2017
@kamipo kamipo deleted the add_statement_timeout_exception branch November 13, 2017 11:15
@jeremy
Copy link
Member

jeremy commented Nov 13, 2017

Yes!

kamipo added a commit to kamipo/rails that referenced this pull request Nov 25, 2017
Since rails#31129, new error class `StatementTimeout` has been added.
`TransactionTimeout` is caused by the timeout shorter than
`StatementTimeout`, but its name is too generic. I think that it should
be a name that understands the difference with `StatementTimeout`.
kamipo added a commit that referenced this pull request Nov 27, 2017
…1223)

Since #31129, new error class `StatementTimeout` has been added.
`TransactionTimeout` is caused by the timeout shorter than
`StatementTimeout`, but its name is too generic. I think that it should
be a name that understands the difference with `StatementTimeout`.
@kamipo kamipo mentioned this pull request Mar 14, 2019
kamipo added a commit to kamipo/rails that referenced this pull request Mar 16, 2019
We as Arm Treasure Data are using Optimizer Hints with a monkey patch
(https://gist.github.com/kamipo/4c8539f0ce4acf85075cf5a6b0d9712e),
especially in order to use `MAX_EXECUTION_TIME` (refer rails#31129).

Example:

```ruby
class Job < ApplicationRecord
  default_scope { optimizer_hints("MAX_EXECUTION_TIME(50000) NO_INDEX_MERGE(jobs)") }
end
```

Optimizer Hints is supported not only for MySQL but also for most
databases (PostgreSQL on RDS, Oracle, SQL Server, etc), it is really
helpful to turn heavy queries for large scale applications.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants