milvus icon indicating copy to clipboard operation
milvus copied to clipboard

[Bug]: EtcdKV CompareAndSwap interface semantic is confused

Open xiaofan-luan opened this issue 3 years ago • 11 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Environment

- Milvus version:
- Deployment mode(standalone or cluster):
- SDK version(e.g. pymilvus v2.0.0rc2):
- OS(Ubuntu or CentOS): 
- CPU/Memory: 
- GPU: 
- Others:

Current Behavior

etcdKV support compareAndSwap by value and version, if compare failed it will throw NewCompareFailedError.

Expected Behavior

  1. compareAndSwap should support idempotent retry.
  2. if version or value mismatch, should return true/false rather than direct return error

Steps To Reproduce

No response

Anything else?

No response

xiaofan-luan avatar Mar 15 '22 08:03 xiaofan-luan

/assign /unassign @xiaofan-luan

Let me take this

XuanYang-cn avatar Mar 21 '22 03:03 XuanYang-cn

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Rotten issues close after 30d of inactivity. Reopen the issue with /reopen.

stale[bot] avatar Apr 20 '22 23:04 stale[bot]

/reopen lets keep tracking this

XuanYang-cn avatar Apr 29 '22 08:04 XuanYang-cn

@XuanYang-cn: Reopened this issue.

In response to this:

/reopen lets keep tracking this

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

sre-ci-robot avatar Apr 29 '22 08:04 sre-ci-robot

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Rotten issues close after 30d of inactivity. Reopen the issue with /reopen.

stale[bot] avatar May 29 '22 09:05 stale[bot]

keep it open for tracking

yanliang567 avatar May 30 '22 01:05 yanliang567

leave it there

xiaofan-luan avatar Jun 20 '22 03:06 xiaofan-luan

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Rotten issues close after 30d of inactivity. Reopen the issue with /reopen.

stale[bot] avatar Jul 20 '22 03:07 stale[bot]

/reopen

XuanYang-cn avatar Aug 08 '22 02:08 XuanYang-cn

@XuanYang-cn: Reopened this issue.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

sre-ci-robot avatar Aug 08 '22 02:08 sre-ci-robot

/unstale

XuanYang-cn avatar Aug 08 '22 02:08 XuanYang-cn

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Rotten issues close after 30d of inactivity. Reopen the issue with /reopen.

stale[bot] avatar Sep 09 '22 22:09 stale[bot]

unstale

XuanYang-cn avatar Sep 16 '22 08:09 XuanYang-cn

Found no usage of these 4 functions, and the bool part is already done.

func (kv *EtcdKV) CompareValueAndSwap(key, value, target string, opts ...clientv3.OpOption) (bool, error)
func (kv *EtcdKV) CompareValueAndSwapBytes(key string, value, target []byte, opts ...clientv3.OpOption) (bool, error)
func (kv *EtcdKV) CompareVersionAndSwap(key string, source int64, target string, opts ...clientv3.OpOption) (bool, error)
func (kv *EtcdKV) CompareVersionAndSwapBytes(key string, source int64, target []byte, opts ...clientv3.OpOption) (bool, error)

One question, I found these ut

  747         success, err = etcdKV.CompareValueAndSwap("a/b/c", "1", "2")                                                              
  748         assert.True(t, success)                                                                                           
  749         assert.NoError(t, err)                                                                                           
  750                                                                                                               
  751         success, err = etcdKV.CompareValueAndSwap("a/b/c", "1", "2")                                                              
  752         assert.NoError(t, err)                                                                                           
  753         assert.False(t, success)  

Dose idempotent means if the first write is a success, then if the value to write is equal to the actual value read, do nothing and return success? @xiaofan-luan

  747         success, err = etcdKV.CompareValueAndSwap("a/b/c", "1", "2")                                                              
  748         assert.True(t, success)                                                                                           
  749         assert.NoError(t, err)                                                                                           
  750                                              
  751         success, err = etcdKV.CompareValueAndSwap("a/b/c", "1", "2")                                                              
  752         assert.NoError(t, err)                                                                                           
  753         *assert.True(t, success)

XuanYang-cn avatar Sep 19 '22 03:09 XuanYang-cn

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Rotten issues close after 30d of inactivity. Reopen the issue with /reopen.

stale[bot] avatar Oct 19 '22 04:10 stale[bot]