zoukankan      html  css  js  c++  java
  • 转 InnoDB Error Handling

    14.20.4 InnoDB Error Handling

    Error handling in InnoDB is not always the same as specified in the SQL standard. According to the standard, any error during an SQL statement should cause rollback of that statement. InnoDB sometimes rolls back only part of the statement, or the whole transaction. The following items describe how InnoDB performs error handling:

    • If you run out of file space in a tablespace, a MySQL Table is full error occurs and InnoDB rolls back the SQL statement.

    • A transaction deadlock causes InnoDB to roll back the entire transaction. Retry the whole transaction when this happens.

      A lock wait timeout causes InnoDB to roll back only the single statement that was waiting for the lock and encountered the timeout. (To have the entire transaction roll back, start the server with the --innodb_rollback_on_timeout option.) Retry the statement if using the current behavior, or the entire transaction if using --innodb_rollback_on_timeout.

      Both deadlocks and lock wait timeouts are normal on busy servers and it is necessary for applications to be aware that they may happen and handle them by retrying. You can make them less likely by doing as little work as possible between the first change to data during a transaction and the commit, so the locks are held for the shortest possible time and for the smallest possible number of rows. Sometimes splitting work between different transactions may be practical and helpful.

      When a transaction rollback occurs due to a deadlock or lock wait timeout, it cancels the effect of the statements within the transaction. But if the start-transaction statement was START TRANSACTION or BEGIN statement, rollback does not cancel that statement. Further SQL statements become part of the transaction until the occurrence of COMMIT, ROLLBACK, or some SQL statement that causes an implicit commit.

    • A duplicate-key error rolls back the SQL statement, if you have not specified the IGNORE option in your statement.

    • A row too long error rolls back the SQL statement.

    • Other errors are mostly detected by the MySQL layer of code (above the InnoDB storage engine level), and they roll back the corresponding SQL statement. Locks are not released in a rollback of a single SQL statement.

    During implicit rollbacks, as well as during the execution of an explicit ROLLBACK SQL statement, SHOW PROCESSLIST displays Rolling back in the State column for the relevant connection.

  • 相关阅读:
    Mybatis分页插件PageHelper使用
    JAVA面试笔记
    基于Fusioncharts的报表统计
    微信支付开发流程
    Java 使用 Jxl 实现 Excel 导入导出
    从navicat中导入sql文件过大:Got a packet bigger than 'max_allowed_packet' bytes
    一个故事告诉你比特币的原理及运作机制
    Linux和Windows下tomcat开机自启动设置
    Linux下安装MySQL
    ubuntu 13.10使用fcitx输入法
  • 原文地址:https://www.cnblogs.com/ly7454/p/4808360.html
Copyright © 2011-2022 走看看