diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-04-24 15:20:14 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-04-24 15:20:14 +0100 |
commit | 7195e67e525af76f264e278e22a2784040c45d46 (patch) | |
tree | 5825044ec29145b95b61fe781113b1046ca6c4ce /app/models/info_request.rb | |
parent | 4929b1e738d15d2178e131701027ef20492599d9 (diff) | |
parent | d3aae5cc48c92473e06b2104bb9431305d5a92f0 (diff) |
Merge branch 'release/0.9'0.9
Conflicts:
locale/cs/app.po
locale/he_IL/app.po
locale/id/app.po
locale/it/app.po
locale/ro_RO/app.po
locale/uk/app.po
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r-- | app/models/info_request.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 237364f56..eaed25a61 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -474,6 +474,17 @@ public incoming_message = IncomingMessage.new ActiveRecord::Base.transaction do + + # To avoid a deadlock when simultaneously dealing with two + # incoming emails that refer to the same InfoRequest, we + # lock the row for update. In Rails 3.2.0 and later this + # can be done with info_request.with_lock or + # info_request.lock!, but upgrading to that version of + # Rails creates many other problems at the moment. In the + # interim, just use raw SQL to do the SELECT ... FOR UPDATE + raw_sql = "SELECT * FROM info_requests WHERE id = #{self.id} LIMIT 1 FOR UPDATE" + ActiveRecord::Base.connection.execute(raw_sql) + raw_email = RawEmail.new incoming_message.raw_email = raw_email incoming_message.info_request = self |