`
san_yun
  • 浏览: 2652384 次
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

mysql Deadlock

 
阅读更多


[2013-06-17 22:19:05,826] {ERROR api_views.api_like - 934} Traceback (most recent call last):
  File "/data1/dist/app/main/duitang/api/api_views.py", line 932, in api_like
    liked = form.save()
  File "/data1/dist/app/main/duitang/like/forms.py", line 83, in save
    liked = like_it(like_object, category)
  File "/data1/dist/app/main/duitang/like/forms.py", line 62, in like_it
    liked, created = Like.objects.get_or_create(user=self.user, category=category, object_id=like_object.id)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/manager.py", line 135, in get_or_create
    return self.get_query_set().get_or_create(**kwargs)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/query.py", line 385, in get_or_create
    obj.save(force_insert=True, using=self.db)
  File "/data1/dist/app/main/duitang/like/models.py", line 54, in save
    super(Like, self).save(*args, **kwargs)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/base.py", line 460, in save
    self.save_base(using=using, force_insert=force_insert, force_update=force_update)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/base.py", line 553, in save_base
    result = manager._insert(values, return_id=update_pk, using=using)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/manager.py", line 195, in _insert
    return insert_query(self.model, values, **kwargs)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/query.py", line 1436, in insert_query
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 791, in execute_sql
    cursor = super(SQLInsertCompiler, self).execute_sql(None)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
    cursor.execute(sql, params)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 86, in execute
    return self.cursor.execute(query, args)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
OperationalError: (1213, 'Deadlock found when trying to get lock; try restarting transaction')

[2013-06-17 22:19:06,190] {ERROR async._worker - 100} async worker [duitang.callback.mblogsync.update_message] [(<Message: 转发 <#81375380>>,)] [{}] err: [Traceback (most recent call last):
  File "/data1/dist/app/main/duitang/common/async.py", line 91, in _worker
    profiling(func, "async")(*a, **kw)
  File "/data1/dist/app/main/duitang/common/async.py", line 19, in _profiling
    r = func(*a, **kw)
  File "/data1/dist/app/main/duitang/callback/mblogsync.py", line 51, in update_message
    mon_album = get_or_create_mongo_album(msg)
  File "/data1/dist/app/main/duitang/callback/mblogsync.py", line 26, in get_or_create_mongo_album
    alb_id, alb_name = get_album_info(msg)
  File "/data1/dist/app/main/duitang/callback/mblogsync.py", line 19, in get_album_info
    album = msg.album
  File "/data1/dist/app/main/duitang/message/models.py", line 273, in __getattribute__
    return super(Message, self).__getattribute__(name)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/fields/related.py", line 315, in __get__
    rel_obj = QuerySet(self.field.rel.to).using(db).get(**params)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/query.py", line 349, in get
    % self.model._meta.object_name)
DoesNotExist: Album matching query does not exist.
]
[2013-06-17 22:19:06,861] {ERROR views.callback - 496} Cannot login via sina, code: cab614ffc313e0b0b29f4e78e988c09e
[2013-06-17 22:19:25,800] {ERROR api_views.api_like - 934} Traceback (most recent call last):
  File "/data1/dist/app/main/duitang/api/api_views.py", line 932, in api_like
    liked = form.save()
  File "/data1/dist/app/main/duitang/like/forms.py", line 83, in save
    liked = like_it(like_object, category)
  File "/data1/dist/app/main/duitang/like/forms.py", line 62, in like_it
    liked, created = Like.objects.get_or_create(user=self.user, category=category, object_id=like_object.id)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/manager.py", line 135, in get_or_create
    return self.get_query_set().get_or_create(**kwargs)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/query.py", line 385, in get_or_create
    obj.save(force_insert=True, using=self.db)
  File "/data1/dist/app/main/duitang/like/models.py", line 54, in save
    super(Like, self).save(*args, **kwargs)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/base.py", line 460, in save
    self.save_base(using=using, force_insert=force_insert, force_update=force_update)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/base.py", line 553, in save_base
    result = manager._insert(values, return_id=update_pk, using=using)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/manager.py", line 195, in _insert
    return insert_query(self.model, values, **kwargs)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/query.py", line 1436, in insert_query
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 791, in execute_sql
    cursor = super(SQLInsertCompiler, self).execute_sql(None)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
    cursor.execute(sql, params)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 86, in execute
    return self.cursor.execute(query, args)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
OperationalError: (1213, 'Deadlock found when trying to get lock; try restarting transaction')

分享到:
评论

相关推荐

    mysql报错:Deadlock found when trying to get lock; try restarting transaction的解决方法

    在描述的场景中,程序在尝试更新数据时遇到了"Deadlock found when trying to get lock; try restarting transaction"的错误,这表明存在一个死锁情况。在InnoDB存储引擎中,这种错误会导致其中一个事务被回滚,以便...

    MySQL死锁的产生原因以及解决方案

    MySQL数据库在多用户并发操作中,为了保证数据的一致性和完整性,使用了锁机制来管理事务的并发控制。死锁是并发控制中的一种异常状态,通常发生在两个或多个事务之间,由于相互等待对方释放资源而形成僵局。本文将...

    避免或最小化mysql死锁deadlock一些方法.docx

    "MySQL 死锁避免和最小化方法" 在 MySQL 中,死锁是指两个或多个事务之间的资源竞争,导致事务无法继续执行的情况。死锁可能会导致数据库性能下降,甚至整个数据库无法访问。为了避免或最小化 MySQL 死锁,需要了解...

    mysql死锁检测机制初探1

    MYSQL 死锁检测机制初探 在 MySQL 中,死锁检测机制是一种重要的机制,用于检测和解决事务之间的死锁问题。在本文中,我们将详细介绍 MySQL 死锁检测机制的原理和实现。 一、死锁的定义和原理 在 MySQL 中,死锁...

    mysql innodb死锁问题详解.docx

    MySQL的InnoDB存储引擎在处理并发事务时可能会遇到死锁问题,这主要发生在多个事务互相等待对方释放资源的情况下。死锁通常由四个必要条件引发: 1. 互斥条件:资源只能被一个事务使用。 2. 请求和保持条件:一个...

    【Linux系统无法访问MySQL数据库怎么办】-sql无法访问数据库-.doc

    当遇到无法访问MySQL数据库时,可能会出现如描述中的异常情况:“ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@75d634ea -- APPARENT DEADLOCK!...

    MySQL 8.0的新特性简述

    - 新的`innodb_deadlock_detect`变量允许在高并发环境下禁用死锁检测以提高效率。 6. **字符集支持**: 默认字符集从latin1升级到utf8mb4,提供了更广泛的Unicode字符支持,包括新的排序规则。 7. **增强JSON...

    一个最不可思议的MySQL死锁分析1

    MySQL中的死锁问题是一个复杂而微妙的议题,尤其是在数据库优化和并发控制中。本文将深入探讨一个看似不可能发生的死锁案例,并分析其背后的原理。死锁通常发生在多个事务相互等待对方释放资源的情况下,但在这个...

    mysql性能优化与诊断

    - **Latest Detect Deadlock**:最近检测到的死锁情况。 - **File I/O**:文件I/O操作统计,包括读写次数、速度等。 - **Insert Buffer and Adaptive Hash Index**:插入缓冲区和自适应哈希索引的状态。 - **Log**:...

    MYSQL 数据库死锁

    - 错误返回:被回滚的事务会收到错误1213(Deadlock found when trying to get lock; try restarting transaction),提示开发者检查并解决可能导致死锁的代码逻辑。 了解了死锁的基本概念后,我们可以通过实际例子...

    mysql死锁分析

    ### MySQL死锁分析 #### 死锁问题背景 在MySQL的使用过程中,死锁是一个较为常见的现象,尤其是在并发量较大的应用场景下。死锁的发生往往会给系统带来不可预知的影响,严重时甚至会导致整个数据库服务不可用。...

    mysql学习代码、实验楼.zip

    6. **事务与并发控制**:学习如何使用事务(TRANSACTION)确保数据的一致性,以及理解隔离级别(READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE)和死锁(Deadlock)的概念。 7. **存储引擎**:...

    MySQL写输入时崩溃SQLAlchemy-0.7.8.zip

    "mysql 死锁 Deadlock found when trying to get lock; try restarting transaction - hehaibo - ITeye技术网站.mht"这个文件可能包含有关如何识别和解决MySQL死锁的详细信息。解决死锁通常包括重新组织事务的顺序,...

    mysql怎么减少行锁对性能的影响

    ### MySQL如何减少行锁对性能的影响 在MySQL数据库中,行锁是一种重要的锁定机制,它主要应用于InnoDB存储引擎中,用于控制并发事务对数据行的访问。行锁的使用可以显著提高系统的并发处理能力,但同时也会带来一定...

    MySQL 8.0的新特性简述.pdf

    - 新的动态变量 `innodb_deadlock_detect` 可用于在必要时禁用死锁检测,以提高高并发环境下的性能。 6. 字符集支持: 默认字符集从 latin1 更改为 utf8mb4,提供更好的 Unicode 支持,新增了 utf8mb4_ja_0900_as...

    mysql死锁的一些案例

    3. **死锁检测**:利用`innodb_deadlock_detect`配置选项,可以开启或关闭死锁检测。 4. **程序逻辑优化**:在应用层检查并避免可能导致死锁的操作,如一次性获取所有需要的资源,或者在循环中尽早释放不再需要的锁...

Global site tag (gtag.js) - Google Analytics