Skip to content
New issue

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

对更新单行记录的优化如何保证幂等? #99

Open
workplaylifecycle opened this issue Oct 29, 2019 · 1 comment
Open

对更新单行记录的优化如何保证幂等? #99

workplaylifecycle opened this issue Oct 29, 2019 · 1 comment

Comments

@workplaylifecycle
Copy link

workplaylifecycle commented Oct 29, 2019

https://github.com/alibaba/AliSQL/wiki/Changes-in-AliSQL-5.6.32-(2016-10-14)
https://github.com/alibaba/AliSQL/wiki/AliSQL-Performance-benchmark-for-inventory
https://github.com/alibaba/AliSQL/wiki/alisql_ic.lua

看到这里根据hint可以自动提交,但是如何保证幂等性,最简化的做法是根据订单查询流水,如果没有流水则INSERT订单,UPDATE库存,INSERT+UPDATE是在一个事务,订单通过唯一键约束,但是这里更新库存直接提交了,怎么确保是否应该提交,是否是订单重入的请求?

@workplaylifecycle workplaylifecycle changed the title 对更新单号记录的优化如何保证幂等? 对更新单行记录的优化如何保证幂等? Oct 29, 2019
@workplaylifecycle
Copy link
Author

执行绑定参数变量

if (!error && thd->lex->ci_on_success)

执行UPDATE操作 #L3456

if (!res && lex->ci_on_success)

执行INSERT操作 #L3611

if (!res && lex->ci_on_success)

外层兜底 #L6616

if (!error && lex->ci_on_success)

从代码看,这个直接调用了commit/rollback,结束了事务,那么幂等流水是什么时间写的呢,INSERT幂等流水和UPDATE库存不在一个事务里,是如何保证幂等的呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant