database_cleaner
database_cleaner copied to clipboard
ActiveRecord::ConnectionNotEstablished in random places
Hi team, sometimes we have this error during running the tests
Randomized with seed 38777
..........................F
An error occurred in an `after(:context)` hook.
Failure/Error: DatabaseCleaner.clean_with(:truncation, except: %i[translations])
ActiveRecord::ConnectionNotEstablished:
connection to server at "127.0.0.1", port 5432 failed: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
Randomized with seed 59497
...........*..................................................F
An error occurred in an `after(:context)` hook.
Failure/Error: DatabaseCleaner.clean_with(:truncation, except: %i[translations])
ActiveRecord::ConnectionNotEstablished:
connection to server at "127.0.0.1", port 5432 failed: FATAL: the database system is shutting down
we run them in parallel
and I have no idea where to find roots of the problem
I tried to set reaping_frequency: 0
setting but it didn't help (logs from runs with this setting)
Versions:
- database_cleaner-active_record (2.1.0)
- database_cleaner-core (2.0.1)
- rails (7.1.3.4)
- rspec-core (3.13.0)
Tests crash in random places and often a restart helps, we don't have something special for database cleaner, our config: rails_helper.rb:
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
end
config.around do |example|
DatabaseCleaner.cleaning do
example.run
end
end
config.after(:all) do
DatabaseCleaner.clean_with(:truncation, except: %i[translations])
end