DatabaseCleaner triggering `before` hook while threads are still running
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Issue không cung cấp tệp nào của repository hoặc test bị lỗi; hãy bắt đầu với các hook RSpec.configure trong config được đăng và vòng đời before/after của DatabaseCleaner. Tái hiện controller spec bằng Future của concurrent-ruby với transaction strategy, sau đó so sánh thời điểm cleanup với thời điểm Future hoàn tất. Được xem là hoàn thành khi race được tái hiện và nguyên nhân cùng cách giải quyết hoặc giới hạn của nó được ghi lại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
This one is hard to reproduce, might not have anything to do with DC but I tracked the issue down to the DC configuration/behavior.
I have a code that runs a couple of operations on threads, using concurrent-ruby's Future. It goes along these lines:
Rails.application.executor.wrap do
future = Concurrent::Future.execute do
Rails.application.executor.wrap(executor: executor) do
operation_that_finds_a_user_on_db
end
end
values = ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
future.value!
end
end
when I'm running controller specs that invoke this part of code, they fail and the exception is that there are no users on the database anymore. I tracked the issue down to DC doing a clean-up.
It looks like DC is running even though Futures are not finished yet. I can't say that this is an issue with DC but I figure that this could be a starting point
Here is my whole config file
RSpec.configure do |config|
DatabaseCleaner.allow_remote_database_url = true if Rails.env.test?
config.before(:suite) do
DatabaseCleaner.clean_with(:deletion)
end
config.before do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, js: true) do
DatabaseCleaner.strategy = :deletion
end
config.before do
DatabaseCleaner.start
end
config.after do
DatabaseCleaner.clean
end
end
Does this make any sense?
Edit: I noticed that changing the strategy from transaction to deletion or truncation worked but the tests got SO much slower that it's not even an option
- Ngôn ngữ chính
- Ruby
- Star
- 3k
- Fork
- 485
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của DatabaseCleaner/database_cleaner
-
:transaction strategy: uncommitted data disappears after perform_enqueued_jobs on Rails ≥ 7.2Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 67/100
-
Cleaning of dev DBĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
Cannot truncate a table referenced in a foreign key constraint (ActiveRecord::StatementInvalid)Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
DatabaseCleaner/database_cleaner#717 · 5 bình luận · 1 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
DatabaseCleaner/database_cleaner#716 · 2 bình luận ·
Tất cả issue của DatabaseCleaner/database_cleaner
Issue tương tự
-
security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ds-drift
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
we-promise/sure#3934 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 7 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
simp/pupmod-simp-ssh#246 ·