Skip to content

Commit d467efc

Browse files
committed
Remove lock_thread on connection pool
The commit that added lock_thread (f638085) notes that > Transaction management is largely ripped straight out of > test_fixtures.rb in Rails The commit that adds lock_thread in Rails -- rails/rails@d6466be -- has some helpful context: > When a system test starts Puma spins up one thread and Capybara spins > up another thread. Because of this when tests are run the database > cannot see what was inserted into the database on teardown. This is > because there are two threads using two different connections. > This change uses the statement cache to lock the threads to using a > single connection ID instead of each not being able to see each other. So lock_thread exists because there are two different threads -- Puma and Capybara -- trying to access the same database but not necessarily seeing the same thing. But! cypress-rails doesn't use Capybara, and more importantly, it doesn't use tests or a test runner written in Ruby at all, so there's only _one_ thread trying to use the database. So we don't need all this thread locking stuff. So let's remove it to make things more compatible with Rails 7.2.
1 parent 86c7cbd commit d467efc

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

lib/cypress-rails/manages_transactions.rb

-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def begin_transaction
1010
@connections = gather_connections
1111
@connections.each do |connection|
1212
connection.begin_transaction joinable: false, _lazy: false
13-
connection.pool.lock_thread = true
1413
end
1514

1615
# When connections are established in the future, begin a transaction too
@@ -26,7 +25,6 @@ def begin_transaction
2625

2726
if connection && !@connections.include?(connection)
2827
connection.begin_transaction joinable: false, _lazy: false
29-
connection.pool.lock_thread = true
3028
@connections << connection
3129
end
3230
end
@@ -42,7 +40,6 @@ def rollback_transaction
4240

4341
@connections.each do |connection|
4442
connection.rollback_transaction if connection.transaction_open?
45-
connection.pool.lock_thread = false
4643
end
4744
@connections.clear
4845

0 commit comments

Comments
 (0)