我在视图中的transaction.atomic()中有一个代码块。我的问题是,Django是否在幕后创建了一些内置的表锁。在django中创建原子事务是否自动创建一个锁
with transaction.atomic():
#code block that does database operations
update_user() #this updates user table
create_customer_products() #this updates user id to customer products table
原因是我运行代码块时出现“超出锁定等待超时;尝试重新启动事务”错误。
的设置是在CentOS
请描述您的环境并添加相关代码。 –
这是从MySQL返回的错误。 https://stackoverflow.com/questions/5836623/getting-lock-wait-timeout-exceeded-try-restarting-transaction-even-though-im – planet260
是的,这是由mysql返回的错误。这让我想知道是否有使用transaction.atomic()时由django设置的锁。因为我没有在任何地方锁定桌子。 –