小编Nic*_*ale的帖子

MySql错误>超出锁定等待超时; 尝试重新启动事务SQLState:41000 VendorError:1205

多年来我一直在研究这个问题,但从来没有能够深入到底.我不知道是什么原因导致这些锁定.

错误是: Lock wait timeout exceeded; try restarting transaction SQLState: 41000 VendorError: 1205

SQL语句是在事务中运行的单个insert语句.所有刀片都是这种形式,所以没有批量插入,也没有混合模式插入等.

INSERT INTO attachment( id, entityid, entitytype , addeduserid , deleteduserid , fullpath , filename, status, creationdate, lastupdated, deletiondate, hasfile,notes,history,type,mimeinfo,archivedby,archivedon, referencedate,changedby,changedon ) values (0,0,2,360,null,NULL,NULL,1,'2013-02-20 08:45:31','2013-02-20 08:45:31',NULL,0,NULL,'20/02/2013 08:45:UserA:File uploaded internally. <br>',0,NULL,null,NULL,NULL,null,NULL);

系统配置:Mysql版本:'服务器版:5.1.61源代码分发'(在Redhat上)

储存:INNODB

INNODB相关配置(部分由my.cnf编辑):

innodb_file_per_table=1
innodb_buffer_pool_size=3G
innodb_additional_mem_pool_size=20M
innodb_log_file_size=512M
innodb_log_files_in_group=2
innodb_log_buffer_size=16M
innodb_support_xa=1
innodb_doublewrite=1
innodb_thread_concurrency=0
innodb_flush_log_at_trx_commit=2
innodb_autoinc_lock_mode=2**
innodb_rollback_on_timeout=1
innodb_locks_unsafe_for_binlog=1**
thread_cache_size=8
query_cache_size=256M
query_cache_limit=4M
table_cache=2048
table_definition_cache=1024
tmp_table_size=512M
max_heap_table_size=512M
transaction-isolation=READ-COMMITTED**
innodb_table_locks=0**
innodb_lock_wait_timeout=50**
Run Code Online (Sandbox Code Playgroud)

**这些都是针对这个问题专门添加的.

通常:

系统(即有6个应用程序实例,每个应用程序实例都具有相同的数据库结构,都在一个mysql实例上运行)可以运行好几天,然后可以运行Lock Waits开始发生,并且通常会让它们在这段时间内出现在组中当天 每个错误都会重复出现,因为一旦失败,我会再次尝试,通常重新尝试将失败.我已配置重试4次.通常,锁只会出现在几个不同的表中.

今天特定的问题实例:

今天早上在attachment桌子上,自昨晚以来没有在桌子上插入.自前一天晚上以来,桌面上也没有任何更新.如果锁与执行更新和插入的其他用户无关,那么某些select语句是否会导致锁定?我试图确保所有选择语句都使用attachment_general_index? …

mysql locking

8
推荐指数
2
解决办法
4万
查看次数

标签 统计

locking ×1

mysql ×1