Enqueue jobs inside a connected_to block
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
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Ruby
- Star
- 2.5k
- Fork
- 250
- Merge trung bình
- 8 giờ 31 phút
- Pull request đã merge (30 ngày)
- 5
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
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 rails/solid_queue
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
rails/solid_queue#806 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
rails/solid_queue#805 ·
-
limits_concurrency on_conflict: :discard looking only into running jobs and not blocked jobs Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
rails/solid_queue#804 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
rails/solid_queue#802 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
rails/solid_queue#797 ·
Tất cả issue của rails/solid_queue
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
riscv/riscv-unified-db#2626 ·
-
Component: GLib
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
ds-drift
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
we-promise/sure#3693 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
simp/pupmod-simp-simp#395 ·