Skip to content
Snippets Groups Projects

Disable Sidekiq worker open transaction check in JS specs

Merged Stan Hu requested to merge sh-disable-sidekiq-open-transaction-tests-js into master
All threads resolved!
3 files
+ 41
2
Compare changes
  • Side-by-side
  • Inline
Files
3
  • When transactional tests are enabled, Rails ensures that all threads
    use the same connection for accessing the database. However this may
    cause a false positive with the Sidekiq worker open transaction
    check because:
    
    1. A browser may have multiple requests in-flight.
    2. A transaction may start in the middle of another request. For example,
    an update to a merge request column initiates a transaction via SAVEPOINT.
    
    To avoid false positives, disable this check for JavaScript feature
    specs run. The alternative is to use the deletion strategy, but that
    would significantly slow tests.
    
    Relates to #478601
@@ -13,6 +13,16 @@ def self.skipping_transaction_check(&block)
end
def self.skip_transaction_check
# When transactional tests are in use, Rails calls
# ConnectionPool#lock_ethread= to ensure all application threads
# get the same connection so they can all see the data in the
# uncommited transaction. If Puma is in use, check the state of
# the lock thread.
if ::Rails.env.test?
lock_thread = ::ApplicationRecord.connection_pool.instance_variable_get(:@lock_thread)
return true if lock_thread && lock_thread[:sidekiq_worker_skip_transaction_check]
end
Thread.current[:sidekiq_worker_skip_transaction_check]
end
Loading