什么是瞬态数据库错误处理在高并发的Rails系统“最佳实践”? [英] What are 'best practices' for dealing with transient database errors in a highly concurrent Rails system?

查看:129
本文介绍了什么是瞬态数据库错误处理在高并发的Rails系统“最佳实践”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然研究死锁问题,我发现了以下职位:

While researching a deadlock issue, I found the following post:

https://rails.lighthouseapp.com/projects/8994/tickets/6596

它的要点如下:

  1. MySQL的文档说:

  1. the MySQL docs say:

死锁是一个经典的问题,在事务型数据库,但它们并不危险,除非他们是如此频繁,你不能运行某些交易的。通常情况下,您必须编写你的应用程序,使他们总是$ ppared重新发出一个事务p $如果它被回滚因为死锁

Deadlocks are a classic problem in transactional databases, but they are not dangerous unless they are so frequent that you cannot run certain transactions at all. Normally, you must write your applications so that they are always prepared to re-issue a transaction if it gets rolled back because of a deadlock.

因此​​调试瞬态死锁是一个反模式,因为MySQL的说,他们是正常的和不可避免的。

  • Therefore debugging transient deadlocks is an antipattern because MySQL says they are OK and unavoidable.

    因此​​,轨道应该为我们提供一种方式,因为它:

    Therefore, Rails should offer us a way, because it:

    使得假设有最好的方式做的事情,它的目的是鼓励这样

    makes the assumption that there is the "best" way to do things, and it's designed to encourage that way

    但Rails没有提供我们,让我们使用的是哈克自己动手做事情的方式。

  • but Rails doesn't offer us a way so we are using a hacky DIY thing.

    因此​​,如果这一切是真的,哪里是Rails的解决方案?

    So if all of this is true, where is the Rails solution?

    注:此项目是无效的,但看起来很简单,是一个解决办法。为什么Rails的不是有这样的事情? https://github.com/qertoip/transaction_retry

    NOTE: This project is inactive, but seems simple enough to be a solution. Why does Rails not have something like this? https://github.com/qertoip/transaction_retry

    推荐答案

    的修复,对我来说,是一个更好的指标。

    The fix, for me, was a better index.

    在讨论的更新是一个连接的查询,和现有的指标不足以为MySQL的加入和搜索效率。

    The update in question was in a query with a join, and existing indexes were not sufficient for MySQL to join and search efficiently.

    添加相应的指数,即使在不合理的并发负载测试中完全删除僵局问题。

    Adding the appropriate index completely removed the deadlock issue even in tests with unreasonably concurrent loads.

    这篇关于什么是瞬态数据库错误处理在高并发的Rails系统“最佳实践”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆