解决:ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction

查看文章
   
from http://hi.baidu.com/sabor/blog/item/6e863c1f5d705171f724e429.html

今天导入数据的时候出现这样的问题了,傻乎乎的不明白是怎么一回事..百度跟google了半天都是解决linux下的..终于黄天不负有心人让我google到了解决办法..

 

This is my configuration file:

# Data node default setting.
[NDBD DEFAULT]
NoOfReplicas=2
DataMemory=400M
IndexMemory=50M
DiskPageBufferMemory=10024K
SharedGlobalMemory=80M
MaxNoOfConcurrentOperations=500000
MaxNoOfOrderedIndexes=512
TimeBetweenLocalCheckpoints=30
TransactionDeadLockDetectionTimeOut=10000
# TCP/IP options:
[TCP DEFAULT]
#portnumber=2202
SendBufferMemory=1024K

 

还有记下:

http://imysql.cn/docs/MySQL_51_zh/storage-engines.html#innodb-troubleshooting 

 http://www.mysqlperformanceblog.com/2009/04/15/how-to-decrease-innodb-shutdown-times/

MySQL官方手册介绍 影响到InnoDB关闭的参数有

innodb_fast_shutdown

如果你把这个参数设置为0,InnoDB在关闭之前做一个完全净化和一个插入缓冲合并。这些操作要花几分钟时间,在极端情况下要几个小时。

如果你设置这个参数为1,InnoDB在关闭之时跳过这些操作。 默认值为1。

如果你设置这个值为2 (在Netware无此值), InnoDB将刷新它的日志然后冷关机,仿佛MySQL崩溃一样。已提交的事务不会被丢失,但在下一次启动之时会做一个崩溃恢复。


innodb_max_dirty_pages_pct

这是一个范围从0到100的整数。默认是90。InnoDB中的主线程试着从缓冲池写页面,使得脏页(没有被写的页面)的百分比不超过这个值。如果你有SUPER权限,这个百分比可以在服务器运行时按下面来改变:

SET GLOBAL innodb_max_dirty_pages_pct =value;

----------------------------

1.5.1. Differences Between the NDB and InnoDB Storage Engines

The MySQL Cluster NDB storage engine is implemented using a distributed, shared-nothing architecture, which causes it to behave differently from InnoDB in a number of ways. For those unaccustomed to working with NDB, unexpected behaviors can arise due to its distributed nature with regard to transactions, foreign keys, joins, and other characteristics. These are shown in the following table:

Feature

InnoDB

MySQL Cluster (NDB)

MySQL Server Availability

5.5 (in latest MySQL 5.5 GA release)

5.1

(MySQL Cluster NDB 7.0 and 7.1 SQL nodes currently based on MySQL 5.1.56 GA; MySQL 5.5-based MySQL Cluster NDB 7.2 in development)

InnoDB Availability

InnoDB 1.1 plugin

NDB 6.3, 7.0InnoDB storage engine

NDB 7.1InnoDB 1.0 plugin support, as of MySQL Cluster NDB 7.1.9a

Storage Limits

64TB

2TB

(Practical upper limit for database size)

Foreign Keys

Yes

No

(Foreign keys ignored, as with MyISAM)

Transactions

All standard types

Only READ COMMITTED supported

MVCC Non-Blocking Reads

Yes

(Read concurrency without locks)

No

Multi-Table Join Performance

Good

Poor

(In MySQL Cluster NDB 7.2, the performance of many joins can be greatly enhanced by pushing them down to the data nodes; see the description of thendb_join_pushdown system variable andthis MySQL Dev Zone article for more information)

Data Compression

Yes

No

(MySQL Cluster checkpoint and backup files can be compressed)

Large Row Support (> 8K)

Supported for VARBINARYVARCHARBLOB, and TEXT columns

Supported for BLOB and TEXT columns only

(Using these types to store very large amounts of data can lower MySQL Cluster performance)

Virtualization

No

(Not supported in virtual environments)

No

(Not supported in virtual environments)

Minimum Number of Physical Hosts for Redundancy

2: 1 active, 1 passive

3: 2 data nodes, 1 management node

Availability (HA)

Requires additional software

Yes (99.999%)

Node Failure Recovery and Failover

Requires additional software

Automatic

(Key element in MySQL Cluster architecture)

Time for Node Failure Recovery

30 seconds to several hours

< 1 second

Real-Time Performance

No

Yes (Low latency)

In-Memory Storage

No

Yes

(Some data can optionally be stored on disk; both in-memory and disk data storage are durable)

Direct (non-SQL) API Access to Storage Engine

Native memcached interface in development (see the MySQL Dev Zone article NoSQL to MySQL with Memcached)

Yes

Multiple APIs, including C++, HTTP/REST, Java, and JPA; memcached in development (see NoSQL to MySQL with Memcached)

Scalability

(Read scalability using MySQL Replication; write scalability by means of application-level partitioning)

Good

(Automatic partitioning of the database provides scalability for both read and write operations)

Concurrent and Parallel Writes

Not supported

Up to 48 writers, optimized for concurrent writes

(MySQL Cluster supports up to 48 data nodes for processing, with 24 nodes for storage, due to requirements for two-fold redundancy)

Conflict Detection and Resolution (Multiple Replication Masters)

No

Yes

(True active-active geographic replication, in which each application node can read or write to its own local database)

Hash Indexes

No

Yes

(Can provide fast access to key/value data)

On-Line Addition of Nodes Read-only replicas using MySQL Replication All node types—management, data, and API/SQL nodes
Online Schema Modifications No Yes

15.4.1.27. Replication Retries and Timeouts

The global system variable slave_transaction_retries affects replication as follows: If the slave SQL thread fails to execute a transaction because of an InnoDB deadlock or because it exceeded the InnoDB innodb_lock_wait_timeout value, or the NDBCLUSTER TransactionDeadlockDetectionTimeout or TransactionInactiveTimeout value, the slave automatically retries the transaction slave_transaction_retries times before stopping with an error. The default value is 10. The total retry count can be seen in the output of SHOW STATUS; see Section 5.1.5, “Server Status Variables”. 



  1. #1
    Database Administrator
    Database Bot
    Join Date
    Sep 2009
    Posts
    1,234,884
    Rep Power
    1237

    error : Lock wait timeout exceeded; try restarting transaction

    hello friends,


    i am trying to create a java application using mysql but if i try to
    create multiple connections, i keep on getting this exception given
    below. I have read about the TransactionDeadLockDetectionTimeOut
    option but i am neither able to find config.ini nor i am running the
    cluster for which this option applies.


    what could be the problem here ?

    thanks
    ravinder thakur



    java.sql.SQLException: Lock wait timeout exceeded; try restarting
    transaction
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1056)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
    Reply With Quote

  • #2
    Database Administrator
    Database Bot
    Join Date
    Sep 2009
    Posts
    1,234,884
    Rep Power
    1237

    Re: error : Lock wait timeout exceeded; try restarting transaction

    रवींदर à¤*ाकुर (ravinder thakur) wrote:
    > hello friends,
    >
    >
    > i am trying to create a java application using mysql but if i try to
    > create multiple connections, i keep on getting this exception given
    > below. I have read about the TransactionDeadLockDetectionTimeOut
    > option but i am neither able to find config.ini nor i am running the
    > cluster for which this option applies.


    Do things work with one connection?
    Could be that you are having too many connections to the sql server.
    It may be better to have just one connection and see to that the queries made
    uses database names, so you will access the data regardless of which database
    you have originally selected.


    --

    //Aho
    Reply With Quote

  • #3
    Database Administrator
    Database Bot
    Join Date
    Sep 2009
    Posts
    1,234,884
    Rep Power
    1237

    Re: error : Lock wait timeout exceeded; try restarting transaction

    thanks for the super quick response Aho.


    Things do work with single connection. However as soon as i increase
    it, they stop working. Apparently this is due to the small lockout
    time for transaction in mysql (TransactionDeadLockDetectionTimeOut ).
    but i am not able to find out any way to increase it (i cannot even
    find out config.ini that people are talking about on net )


    thanks
    ravinder
    Reply With Quote

  • #4
    Database Administrator
    Database Bot
    Join Date
    Sep 2009
    Posts
    1,234,884
    Rep Power
    1237

    Re: error : Lock wait timeout exceeded; try restarting transaction

    रवींदर à¤*ाकुर (ravinder thakur) wrote:

    > Things do work with single connection. However as soon as i increase
    > it, they stop working. Apparently this is due to the small lockout
    > time for transaction in mysql (TransactionDeadLockDetectionTimeOut ).
    > but i am not able to find out any way to increase it (i cannot even
    > find out config.ini that people are talking about on net )


    As I have understood, the config.ini is used by mysql when setting up a
    cluster environment and don't seem to be a default config file, so it has to
    be created by the user manually.

    http://dev.mysql.com/doc/refman/5.0/...nfig-file.html


    I would urge you to look if you can't make your application to only use one
    connection, at work we had an application that used quite many threads and a
    new connection with each thread, and of course sooner or later it always run
    out of connections and failed badly, requiring a restart (there was other bugs
    too). I believe you will win on the long run, if you can reuse connections.

    --

    //Aho
    Reply With Quote

  • #5
    Database Administrator
    Database Bot
    Join Date
    Sep 2009
    Posts
    1,234,884
    Rep Power
    1237

    Re: error : Lock wait timeout exceeded; try restarting transaction

    got to the problem...


    the problem was in the my.ini file (for windows only) that was to be
    edited and not the config.ini. in this file we have to set the timeout
    by setting innodb_lock_wait_timeout.
    Reply With Quote

  • #6
    Database Administrator
    Database Bot
    Join Date
    Sep 2009
    Posts
    1,234,884
    Rep Power
    1237

    Re: error : Lock wait timeout exceeded; try restarting transaction

    रवींदर à¤*ाकुर (ravinder thakur) wrote:
    > got to the problem...
    >
    >
    > the problem was in the my.ini file (for windows only) that was to be
    > edited and not the config.ini. in this file we have to set the timeout
    > by setting innodb_lock_wait_timeout.


    Good to hear that you managed to solve the trouble.

    --

    //Aho
    Reply With Quote

    + Reply to Thread


  • 你可能感兴趣的:(mysql,scalability,database,application,memcached,join)