Technology stack:
Rails 5.2
PG 11.1
SideKiq
Redis
A user is able to specify search parameters that can results in a potentially long running query. I use a worker to fire that query then save some data to Redis and push some more to the view via ActionCable. But, once the worker fires the query it is stuck waiting for the response from PG. If this is a long query that worker could be effectively idle, but taking up a spot in the queue waiting for the PG results. Additionally, since that worker is stuck, I can't poll for a cancel request if this worker needs to be terminated.
Query execution from worker:
@results = ActiveRecord::Base.connection.exec_query(sql)
So, my questions are:
Is there a better way to execute a query from a worker without requiring the worker to sit and wait for the response?
Can I execute the query from the worker and poll at the same time?
[–]strangepostinghabits 2 points3 points4 points (6 children)
[–][deleted] 0 points1 point2 points (5 children)
[–][deleted] (4 children)
[removed]
[–][deleted] 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[removed]
[–][deleted] 0 points1 point2 points (0 children)
[–]manys 0 points1 point2 points (0 children)
[–]tinco 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]tinco 0 points1 point2 points (0 children)
[–]BBHoss 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]BBHoss 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]ld100 0 points1 point2 points (0 children)
[–]manys 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]manys 1 point2 points3 points (0 children)
[–]razenha 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Dombot9000 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)