<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/992#discussion_r32368451">app/models/relation.rb</a>:</p>
<pre style='color:#555'>> @@ -248,6 +248,9 @@ def preconditions_ok?(good_members = [])
>        model = Kernel.const_get(m[0].capitalize)
>        # get the element with that ID
>        element = model.find_by(:id => m[1])
> +      # if found, lock the element to ensure it can't be deleted until
> +      # after the current transaction commits.
> +      element.lock!("for share") unless element.nil?
</pre>
<p>Should you fold that into the previous line as <code>model.lock("for share").find_by(:id => m[1])</code>? Otherwise there is a race between finding it and locking it where a deletion could still happen?</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/openstreetmap/openstreetmap-website/pull/992/files#r32368451">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABWnLZpBfbm438bgnJyRvu45dzCE_51Oks5oS8hjgaJpZM4FBkjZ.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
    <link itemprop="url" href="https://github.com/openstreetmap/openstreetmap-website/pull/992/files#r32368451"></link>
    <meta itemprop="name" content="View Pull Request"></meta>
  </div>
  <meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>