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

Gracefully handle transactional fixtures leaks #51010

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

casperisfine
Copy link
Contributor

Extracted from: #50999

Some tests may use the connections in ways that cause the fixtures transaction to be committed or rolled back. The typical case being doing schema change query in MySQL, which automatically commits the transaction. But ther eare more subtle cases.

The general idea here is to ensure our transaction is correctly rolling back during teardown. If it fails, then we assume something might have mutated some of the inserted fixtures, so we invalidate the cache to ensure the next test will reset them.

This issue is particularly common in Active Record's own test suite since transaction fixtures are enabled by default but we have many tests create tables and such.

We could treat this case as an error, but since we can gracefully recover from it, I don't think it's worth it.

@casperisfine casperisfine force-pushed the handle-transactional-fixtures-leak branch 2 times, most recently from d99784a to 5af2f73 Compare February 8, 2024 10:07
Extracted from: rails#50999

Some tests may use the connections in ways that cause the fixtures
transaction to be committed or rolled back. The typical case being
doing schema change query in MySQL, which automatically commits the
transaction. But ther eare more subtle cases.

The general idea here is to ensure our transaction is correctly
rolling back during teardown. If it fails, then we assume something
might have mutated some of the inserted fixtures, so we invalidate
the cache to ensure the next test will reset them.

This issue is particularly common in Active Record's own test suite
since transaction fixtures are enabled by default but we have
many tests create tables and such.

We could treat this case as an error, but since we can gracefully
recover from it, I don't think it's worth it.
@casperisfine casperisfine force-pushed the handle-transactional-fixtures-leak branch from 5af2f73 to 26de25d Compare February 8, 2024 10:28
@byroot byroot merged commit 6daddd9 into rails:main Feb 8, 2024
4 checks passed
@fatkodima
Copy link
Member

Looks like this PR introduced some noise to the Postgres tests output https://buildkite.com/rails/rails/builds/104728#018d9028-611d-481d-930b-4f7a31a4f9c0

@byroot
Copy link
Member

byroot commented Feb 11, 2024

Yeah, I noticed that in #50999 (comment), and it will fix it once merged. I'll likely merge it tomorrow. Sorry for the noise.

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.

None yet

3 participants