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

Make batchupdate idempotent #444

Merged
merged 1 commit into from
Jun 25, 2021
Merged

Conversation

jschwinger233
Copy link
Member

本质上要解决的问题依然是 store.UpdateNodes(ctx, n1, n2) 的时候, 如果 n1 数据有变但是 n2 没变的情况, 这个 pr 把检查数据变化的 txn 条件删除了, 让接口变得幂等.

@jschwinger233 jschwinger233 changed the title make batchupdate idempotent Make batchupdate idempotent Jun 25, 2021
@@ -308,7 +308,7 @@ func (e *ETCD) Grant(ctx context.Context, ttl int64) (*clientv3.LeaseGrantRespon
func (e *ETCD) batchUpdate(ctx context.Context, data map[string]string, opts ...clientv3.OpOption) (*clientv3.TxnResponse, error) {
limit := map[string]map[string]string{}
for key := range data {
limit[key] = map[string]string{cmpVersion: "!=", cmpValue: "!="} // ignore same data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这么写的原因在于,减少 etcd 写数据的量

@CMGS CMGS merged commit d0a9c3c into projecteru2:master Jun 25, 2021
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

Successfully merging this pull request may close these issues.

2 participants