DatabaseCleaner triggering `before` hook while threads are still running
还没有人认领这个 Issue。
评估
调研方向
该 issue 没有提供 repository 文件或失败的测试;请从已发布 config 中的 RSpec.configure hooks 以及 DatabaseCleaner 的 before/after 生命周期开始。使用 concurrent-ruby 的 Future 和 transaction strategy 重现 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
- 派生
- 484
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
DatabaseCleaner/database_cleaner 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 67/100
-
难度 4/5 3-5 天 新手友好度 25/100
-
难度 3/5 1-2 天 新手友好度 45/100
-
难度 4/5 3-5 天 新手友好度 35/100
DatabaseCleaner/database_cleaner#717 · 5 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 25/100
DatabaseCleaner/database_cleaner#716 · 2 条评论 ·
查看 DatabaseCleaner/database_cleaner 的全部 Issue
相似的 Issue
-
Dependencies view: `getParent` loops forever on untitled documents, extension host runs out of memory可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
area/web interface
难度 2/5 1-3 小时 新手友好度 62/100
mastodon/mastodon#41000 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 82/100
zerocracy/judges-action#2743 ·
维护者通常 8 天内回复
-
Python 3.15 support可能已有人在做 @amnesiaof 今天认领。 未关闭L: python L: python:uv
难度 2/5 1-3 小时 新手友好度 72/100
dependabot/dependabot-core#16524 · 1 条评论 ·
维护者通常 1 天内回复
-
content good first issue
难度 2/5 1-3 小时 新手友好度 66/100
rubyevents/rubyevents#2182 ·
维护者通常 1 天内回复