响应数据库死锁返回 HTTP 503 是否合适? [英] Is it appropriate to return HTTP 503 in response to a database deadlock?
本文介绍了响应数据库死锁返回 HTTP 503 是否合适?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当请求的操作导致数据库死锁时,服务器返回503(服务不可用")
是否合适?
Is it appropriate for a server to return 503 ("Service Unavailable")
when the requested operation resulted in a database deadlock?
这是我的推理:
- 最初我尝试避免数据库死锁,但我遇到了https://stackoverflow.com/a/112256/14731
- 接下来,我尝试在服务器端重复请求,但遇到了Java Servlets:如何重复 HTTP 请求?.从技术上讲,我可以缓冲请求实体,但可扩展性会受到影响,并且客户端更有可能看到
503 Service Unavailable
.
- Initially I tried avoiding database deadlocks, but I ran across https://stackoverflow.com/a/112256/14731
- 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.
视为:
- 让客户重复操作更容易.
- 他们无论如何都需要能够处理
503 Service Unavailable
. - 数据库死锁相当罕见.
我倾向于这个解决方案.你怎么看?
I'm leaning towards this solution. What do you think?
更新:我认为如果您愿意,返回 503(服务不可用")
仍然是可以接受的,但我不再认为它在技术上是必需的.请参阅https://stackoverflow.com/a/17960047/14731.
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://stackoverflow.com/a/17960047/14731.
推荐答案
我觉得只要整个事务回滚或者请求是幂等的就可以了.
I think it's fine so long as the entire transaction is rolled back or if the request is idempotent.
这篇关于响应数据库死锁返回 HTTP 503 是否合适?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文