简体   繁体   English

Django:通过添加m2m导致“当前事务中止,命令被忽略,直到事务块结束”

[英]Django: Added m2m via through causes 'current transaction is aborted, commands ignored until end of transaction block'

I am trying to add an m2m relationship via a through table and, out of the blue, am encountering the following error: 我试图通过直通表添加m2m关系,并且突然出现了以下错误:

'current transaction is aborted, commands ignored until end of transaction block' “当前事务中止,命令被忽略,直到事务块结束”

There are 2 odd issues about this. 有两个奇怪的问题。 The first is that, I've successfully migrated/synced all of my relevant apps. 首先是,我已经成功迁移/同步了所有相关应用。 The second is that both the associated models and the model in question (AddedFeature) successfully save into the database even if the error is thrown. 第二个原因是,即使引发错误,关联的模型和相关的模型(AddedFeature)也会成功保存到数据库中。 That is, even though the transaction is aborted, the AddedFeature instance is saved to the DB. 也就是说,即使事务中止,AddedFeature实例也将保存到数据库。

http://dpaste.com/1357120/ http://dpaste.com/1357120/

Just to reiterate - refreshing my DB and remigrating/resyncing did not help solve the issue. 只是重申一下-刷新数据库和重新迁移/重新同步并没有帮助解决问题。

Look for the problem that happened before this error. 查找此错误之前发生的问题。 Your code, or code you're using, is ignoring a database error. 您的代码或您正在使用的代码正在忽略数据库错误。 So the next operation fails. 因此,下一个操作失败。

You need to look in the database and/or application logs to find the previous problem. 您需要查看数据库和/或应用程序日志以查找先前的问题。 Then determine what part of your app's code is swallowing a database exception without logging it and aborting the transaction. 然后确定应用程序代码的哪一部分吞没了数据库异常,而没有记录它并中止了事务。

Setting log_statement = 'all' in postgresql.conf can be useful for this. postgresql.conf设置log_statement = 'all'对此很有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 django-当前事务中止,命令被忽略,直到事务块结束 - django - current transaction is aborted, commands ignored until end of transaction block InternalError:当前事务中止,命令被忽略,直到事务块结束 - InternalError: current transaction is aborted, commands ignored until end of transaction block DatabaseError:当前事务被中止,在事务块结束之前忽略命令? - DatabaseError: current transaction is aborted, commands ignored until end of transaction block? django reg extension-当前事务中止,命令被忽略,直到事务块结束 - django reg extend - current transaction is aborted, commands ignored until end of transaction block psycopg2.errors.InFailedSqlTransaction:当前事务被中止,命令被忽略直到事务块结束 - psycopg2.errors.InFailedSqlTransaction: current transaction is aborted, commands ignored until end of transaction block 错误:当前事务中止,创建新记录时命令被忽略,直到事务块结束 - Error: current transaction is aborted, commands ignored until end of transaction block while creating a new record SQLAlchemy + postgres:(InternalError)当前事务中止,命令被忽略,直到事务块结束 - SQLAlchemy + postgres : (InternalError) current transaction is aborted, commands ignored until end of transaction block DatabaseError:当前事务中止,命令被忽略,直到事务块结束-在隐身模式下,但正常情况下没有错误 - DatabaseError: current transaction is aborted, commands ignored until end of transaction block - in incognite mode but no error in normal 如何调试:内部错误当前事务被中止,命令被忽略直到事务块结束 - How to debug: Internal Error current transaction is aborted, commands ignored until end of transaction block 使用 Python 连接到 Redshift 数据 - 错误:当前事务被中止,命令被忽略,直到事务块结束 - Connecting to Redshift Data Using Python - Error: current transaction is aborted, commands ignored until end of transaction block
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM