title: Is it appropriate to return HTTP 503 in response to a database deadlock?
body: <p>Is it appropriate for a server to return <code>503 ("Service Unavailable")</code> when the requested operation resulted in a database deadlock?</p>
  
  <p>Here is my reasoning:</p>
  
  <ul>
  <li>Initially I tried avoiding database deadlocks, but I ran across <a href="https://stackoverflow.com/a/112256/14731">https://stackoverflow.com/a/112256/14731</a></li>
  <li>Next, I tried repeating the request on the server-side, but I ran across <a href="https://stackoverflow.com/q/16620003/14731">Java Servlets: How to repeat an HTTP request?</a>. Technically speaking I can buffer the request entity but scalability will suffer and clients are more likely to see <code>503 Service Unavailable</code> anyway.</li>
  </ul>
  
  <p>Seeing as:</p>
  
  <ul>
  <li>It's easier to ask clients to repeat the operation.</li>
  <li>They need to be able to handle <code>503 Service Unavailable</code> anyway.</li>
  <li>Database deadlocks are rather rare.</li>
  </ul>
  
  <p>I'm leaning towards this solution. What do you think?</p>
  
  <p><strong>UPDATE</strong>: I think returning <code>503 ("Service Unavailable")</code> is still acceptable if you wish it, but I no longer think it is technically required. See <a href="https://stackoverflow.com/a/17960047/14731">https://stackoverflow.com/a/17960047/14731</a>.</p>