We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
众所周知,db.session.commit() 用于提交对数据库的更改。现在的设计中,所有的 commit 都放在数据库操作的专门模块中。虽然这样有助于解耦,但是这个引入了潜在的数据一致性问题。
db.session.commit()
想象这样一个场景:
@route def handle(): result_a = process_a() DB.put_something(result_a) result_b = process_b() DB.put_otherthing(result_b)
实际出现的场景如下 43, 59 行:
wxsls-pyfn/src/pkuphysu_wechat/api/x10n/views.py
Lines 43 to 59 in ff9d4bc
如果 process_b 出了问题,那么数据库中的数据会出现意想不到的矛盾状态,这是我们不想看到的。
process_b
经典的解决方法就是一起 db.session.commit(),两个写入操作一起提交,要么一起成功,要么都别写入,保证了数据的一致性。
所以需要对这部分的设计作更改。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
众所周知,
db.session.commit()
用于提交对数据库的更改。现在的设计中,所有的 commit 都放在数据库操作的专门模块中。虽然这样有助于解耦,但是这个引入了潜在的数据一致性问题。想象这样一个场景:
实际出现的场景如下 43, 59 行:
wxsls-pyfn/src/pkuphysu_wechat/api/x10n/views.py
Lines 43 to 59 in ff9d4bc
如果
process_b
出了问题,那么数据库中的数据会出现意想不到的矛盾状态,这是我们不想看到的。经典的解决方法就是一起
db.session.commit()
,两个写入操作一起提交,要么一起成功,要么都别写入,保证了数据的一致性。所以需要对这部分的设计作更改。
The text was updated successfully, but these errors were encountered: