Skip to content

Commit

Permalink
Fight against the deadlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatas committed Dec 5, 2024
1 parent b9862a8 commit 95403be
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,17 @@ def destroy_all_chunks_for!(klass)
end

config.after(:each) do
DatabaseCleaner.clean
retries = 3
begin
DatabaseCleaner.clean
rescue ActiveRecord::StatementInvalid => e
if e.message =~ /deadlock detected/ && (retries -= 1) > 0
sleep 0.1
retry
else
raise
end
end
end

config.include ActiveSupport::Testing::TimeHelpers
Expand Down

0 comments on commit 95403be

Please sign in to comment.