-
Notifications
You must be signed in to change notification settings - Fork 195
Closed
Description
Hello,
We're having a consistently repeatable problem over here of what we think is a fundamental problem of the MVCC advisory lock model in use here.
I see this code, and it doesn't seem to be effective:
https://github.com/chanks/que/blob/master/lib/que/job.rb#L88
Our Job Runner Looks like:
require 'que'
module ActiveJob
module QueueAdapters
class ImhrJobRunner < ::Que::Job
# Places the que job in job_data["que_ref"]
# which can be picked up by ApplicationJob
def run(job_data)
@job_data = job_data
if que_job_done? # we only need to check cause Que picks up destroyed jobs.
log_rerun_issue_info
else
job_data["que_ref"] = self
ApplicationJob.execute job_data
end
mark_que_job_as_done # if you reach this point it's done
end
public :destroy
private
attr_reader :job_data
def log_rerun_issue_info
Rails.logger.warn "#{self.class.name}: Que tried to rerun #{job_data["job_class"]}: " \
"#{job_data["job_id"]}"
end
def que_job_done?
Rails.cache.exist?(que_job_cache_key)
end
def mark_que_job_as_done
Rails.cache.write(que_job_cache_key, true, expires_in: 10.seconds)
end
def que_job_cache_key
["que-job-done", job_data["job_id"]].join("-")
end
end
end
end
We've added Rails cache which uses redis to ensure that the jobs aren't being run twice.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
