diff options
author | francis <francis> | 2009-01-23 17:14:03 +0000 |
---|---|---|
committer | francis <francis> | 2009-01-23 17:14:03 +0000 |
commit | ede90c8be49f0d79cdb9590fc802c9171c0c7739 (patch) | |
tree | 7b6d7afcd2b68db49d06f5744464b040b59ff7c4 | |
parent | bf6b785fc1de6f6478531ce3c34fe0869e018950 (diff) |
Fix edge case with a record updated twice while indexing it
-rw-r--r-- | vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb index 47a50e1b6..f776fe7c9 100644 --- a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb +++ b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb @@ -514,7 +514,16 @@ module ActsAsXapian for id in ids_to_refresh begin ActiveRecord::Base.transaction do - job = ActsAsXapianJob.find(id, :lock =>true) + begin + job = ActsAsXapianJob.find(id, :lock =>true) + rescue ActiveRecord::RecordNotFound => e + # This could happen if while we are working the model + # was updated a second time by another process. In that case + # ActsAsXapianJob.delete_all in xapian_mark_needs_index below + # might have removed the first job record while we are working on it. + STDOUT.puts("job with #{id} vanished under foot") if verbose + next + end STDOUT.puts("ActsAsXapian.update_index #{job.action} #{job.model} #{job.model_id.to_s}") if verbose begin if job.action == 'update' |