Enqueue jobs inside a connected_to block
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
調査の方向性
Start by reviewing the database.yml configuration and config/initializers/database.rb, then reproduce SomeJob.perform_later inside the ActiveRecord::Base.connected_to block. Trace how SolidQueue chooses its database connection; done means jobs enqueue through the queue database even when the caller is connected to secondary_shard.
索引モデルが issue の本文から書いたものです。
説明
My rails application connects to multiple databases with the configs below:
database.yml
production:
primary_shard:
...
secondary_shard:
...
queue:
...
config/initializers/database.rb
# This is needed due to us using another gem whose model writes to both primary_shard and secondary_shard and its model inherits from ActiveRecord::Base
ActiveRecord::Base.instance_eval do
connects_to shards: {
primary_shard: {
writing: :primary_shard,
},
secondary_shard: {
writing: :secondary_shard,
},
}
end
SolidQueue has been working well, the only time where we cannot enqueue is if we have a block of code like below:
ActiveRecord::Base.connected_to(role: :writing, shard: :secondary_shard) do
# ...
SomeJob.perform_later(some_argument)
# ...
end
I think it is because SolidQueue is trying to insert the job into secondary_shard instead of the queue database. Is there any way to circumvent this besides rewriting the code to call perform_later outside of the connected_to block? SomeJob.perform_later might be called inside a function with the connected_to block so it's quite a big refactor for us.
- 主要言語
- Ruby
- スター
- 2.5k
- フォーク
- 252
- 平均マージ
- 8時間 31分
- マージ済み PR(30日)
- 5
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rails/solid_queue のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
rails/solid_queue#808 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
rails/solid_queue#806 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
rails/solid_queue#805 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
rails/solid_queue#804 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
rails/solid_queue#802 ·
rails/solid_queue の issue をすべて見る
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
TheOdinProject/curriculum#31433 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
stablyai/orca#24145 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
endoflife-date/endoflife.date#11194 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100