DatabaseCleaner triggering `before` hook while threads are still running
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
調査の方向性
このissueにはリポジトリのファイルも失敗するテストも提示されていません。投稿された設定内の RSpec.configure フックと、DatabaseCleaner の before/after ライフサイクルから始めてください。transaction strategy を使い、concurrent-ruby の Future で controller spec を再現してから、クリーンアップのタイミングを Future の完了と比較してください。race が再現され、その原因と解決策または制限が文書化されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Ruby
- スター
- 3k
- フォーク
- 485
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
DatabaseCleaner/database_cleaner のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 67/100
-
Cleaning of dev DBオープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
Cannot truncate a table referenced in a foreign key constraint (ActiveRecord::StatementInvalid)オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
DatabaseCleaner/database_cleaner#717 · コメント 5 件 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
DatabaseCleaner/database_cleaner#716 · コメント 2 件 ·
DatabaseCleaner/database_cleaner の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
betagouv/conseillers-entreprises#4720 ·
メンテナーはふだん 3 日以内に返信
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
zerocracy/judges-action#2692 · コメント 1 件 ·
メンテナーはふだん 6 日以内に返信
-
agent:triaged bug bughunt pm:bundler priority:p1
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
SocketDev/socket-patch#896 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
eurosky-social/eu-haul#32 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
simp/pupmod-simp-auditd#293 ·