Is it appropriate for a server to return 503 ("Service Unavailable")
when the requested operation resulted in a database deadlock?
Here is my reasoning:
- Initially I tried avoiding database deadlocks, but I ran across https://mcmap.net/q/282425/-zero-sql-deadlock-by-design-any-coding-patterns
- Next, I tried repeating the request on the server-side, but I ran across Java Servlets: How to repeat an HTTP request?. Technically speaking I can buffer the request entity but scalability will suffer and clients are more likely to see
503 Service Unavailable
anyway.
Seeing as:
- It's easier to ask clients to repeat the operation.
- They need to be able to handle
503 Service Unavailable
anyway. - Database deadlocks are rather rare.
I'm leaning towards this solution. What do you think?
UPDATE: I think returning 503 ("Service Unavailable")
is still acceptable if you wish it, but I no longer think it is technically required. See https://mcmap.net/q/1627209/-java-servlets-how-to-repeat-an-http-request.
HTTP 504
? – Apocynthion