database_cleaner-sequel icon indicating copy to clipboard operation
database_cleaner-sequel copied to clipboard

Bug Report for JRuby: Fiber#new still creates new Threads

Open joebew42 opened this issue 3 years ago • 0 comments

Hello everyone 👋 ,

Unfortunately there still no solution for jruby/jruby#1169, and we still need the workaround that was removed here 0ec3be3256f57520f671a239c653fcee9eb18475.

This PR is for the sole purpose of demonstrating the issue by providing a working example that can be run locally. It's not meant to be merged. If we agree on re-enabling the workaround 0ec3be3256f57520f671a239c653fcee9eb18475, we can merge the fix proposed in a separate PR #22, and then close this one.

What do you think?

Steps to reproduce the issue

Using CRuby 2.7.2

asdf local use ruby 2.7.2
ruby --version
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]

Setup and run tests without jdbc

bundle install --with development --with cruby_only
bundle exec rspec --tag ~with_jdbc

Everything is working! 👏

Using JRuby 9.2.19 with OpenJDK 13

asdf local ruby jruby-9.2.19.0
ruby --version
jruby 9.2.19.0 (2.5.8) 2021-06-15 55810c552b OpenJDK 64-Bit Server VM 13+33 on 13+33 +jit [darwin-x86_64]

Setup and run tests with jdbc only

bundle install --with development --without cruby_only
bundle exec rspec --tag with_jdbc

Database transactions are not getting rolled back using #start, and #end

Failures:

  1) DatabaseCleaner::Sequel::Transaction using a postgres connection cleaning should clean database
     Failure/Error: expect(connection[:users]).to be_empty
       expected `#<Sequel::JDBC::Postgres::Dataset: "SELECT * FROM \"users\"">.empty?` to be truthy, got false
     # ./spec/database_cleaner/sequel/jdbc_transaction_spec.rb:48:in `block in Sequel'
     # ./spec/database_cleaner/sequel/jdbc_transaction_spec.rb:33:in `block in Sequel'

  2) DatabaseCleaner::Sequel::Transaction using a postgres connection cleaning should work with nested transaction
     Failure/Error: expect(connection[:users]).to be_empty
       expected `#<Sequel::JDBC::Postgres::Dataset: "SELECT * FROM \"users\"">.empty?` to be truthy, got false
     # ./spec/database_cleaner/sequel/jdbc_transaction_spec.rb:68:in `block in Sequel'
     # ./spec/database_cleaner/sequel/jdbc_transaction_spec.rb:33:in `block in Sequel'

  3) DatabaseCleaner::Sequel::Transaction using a postgres connection start/clean should clean database
     Failure/Error: expect(connection[:users]).to be_empty
       expected `#<Sequel::JDBC::Postgres::Dataset: "SELECT * FROM \"users\"">.empty?` to be truthy, got false
     # ./spec/database_cleaner/sequel/jdbc_transaction_spec.rb:81:in `block in Sequel'
     # ./spec/database_cleaner/sequel/jdbc_transaction_spec.rb:33:in `block in Sequel'

  4) DatabaseCleaner::Sequel::Transaction using a postgres connection start/clean should work with nested transaction
     Failure/Error: expect(connection[:users]).to be_empty
       expected `#<Sequel::JDBC::Postgres::Dataset: "SELECT * FROM \"users\"">.empty?` to be truthy, got false
     # ./spec/database_cleaner/sequel/jdbc_transaction_spec.rb:102:in `block in Sequel'
     # ./spec/database_cleaner/sequel/jdbc_transaction_spec.rb:33:in `block in Sequel'

Notes

  • The latest JDBC driver for PostgreSQL is also part of this PR. https://jdbc.postgresql.org/download.html

joebew42 avatar Oct 26 '21 12:10 joebew42