Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable transactions in locking examples
These tests are creating threads and explicit transactions to verify when we're locked or not locked in the database. The Rails 5.1 release notes mention that this type of behavior can cause a deadlock, which we've seen with rails 5.1, and to instead disable transactional tests. Why isn't there a cleaner way to flag examples as transactional or not? Although not elegant, disabling transactional examples before and enabling them after works. From the rails 5.1 release notes: "Transactional tests now wrap all Active Record connections in database transactions. When a test spawns additional threads, and those threads obtain database connections, those connections are now handled specially: The threads will share a single connection, which is inside the managed transaction. This ensures all threads see the database in the same state, ignoring the outermost transaction. Previously, such additional connections were unable to see the fixture rows, for example. When a thread enters a nested transaction, it will temporarily obtain exclusive use of the connection, to maintain isolation. If your tests currently rely on obtaining a separate, outside-of-transaction, connection in a spawned thread, you'll need to switch to more explicit connection management. If your tests spawn threads and those threads interact while also using explicit database transactions, this change may introduce a deadlock. The easy way to opt out of this new behavior is to disable transactional tests on any test cases it affects." https://guides.rubyonrails.org/5_1_release_notes.html
- Loading branch information