Rails 6.1: Skip test if it causes query plan generation error #907
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The test
EagerLoadingTooManyIdsTest#test_eager_loading_too_many_idsis failing on the CI with error:This happens if the SQL Server database is unable to handle the large number of values in the IN clause when generating the query plan. This is a known issue with SQL Server (see https://www.mssqltips.com/sqlservertip/5279/sql-server-error-query-processor-ran-out-of-internal-resources-and-could-not-produce-a-query-plan/).
I have found that the test passes if the database compatibility level is 100/110/120 but fails if it's 130/140. I was going to skip the test based on the compatibility level however "it is possible to generate this error during execution due to limitation of server resources like memory, etc" (https://www.mssqltips.com/sqlservertip/5279/sql-server-error-query-processor-ran-out-of-internal-resources-and-could-not-produce-a-query-plan/).
The issue, when it happens, is with the database instance and not the SQL Server adapter. So by skipping the test
only when the query plan generation fails we can do our best to catch any genuine errors while ignoring a known
SQL Server issue.