Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
worker method that freezes
def calculate!
self.with_lock do
Octopus.using(:replica) do
self.class::CALCULATION_METHODS.each { |method| send(method) }
end
self.updated_at = self.calculated_at = Time.now
self.is_calculated = true
self.save!(touch: false)
end
rescue ActiveRecord::StatementInvalid => e
if e.message.downcase.include?('deadlock')
raise CalculationDeadLock, e.message
else
raise
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.