client-go
client-go copied to clipboard
function RawCAS do not expose parameter 'ttl'
in kvproto project, RawCASRequest defined and include the 'ttl' member, and tikv-server also deal the request with 'ttl' semantic. why does not exposed it to the client api? CAS with ttl seems very useful in many cases.
Thanks @tutububug I think it is a good idea. We may need your opinion /cc @iosmanthus
For now, CAS with TTL is forbidden but removing this restriction should be fine, the next few pull requests for API v2 should fix this.
@iosmanthus Do you have any update for the issue?
@iosmanthus Do you have any update for the issue?
For now, TiKV v5.4.0 has canceled this restriction, but client-go need modify some method signature to support this feature by add a Ttl parameter to grpc request.
ok, thank you. I had forked repository of client-go to modify method signature.
-------- 原始邮件 -------- 发件人: iosmanthus @.> 日期: 2022年2月22日周二 15:58 收件人: tikv/client-go @.> 抄送: tutububug @.>, Mention @.> 主 题: Re: [tikv/client-go] function RawCAS do not expose parameter 'ttl' (Issue #371)
@iosmanthushttps://github.com/iosmanthus Do you have any update for the issue?
For now, TiKV v5.4.0 has canceled this restriction, but client-go need modify some method signature to support this feature by add a Ttl parameter to grpc request.
― Reply to this email directly, view it on GitHubhttps://github.com/tikv/client-go/issues/371#issuecomment-1047518813, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJU3HUGMHQATOYRGUG7JEO3U4M62TANCNFSM5H2FF3ZA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you were mentioned.Message ID: @.***>
In go-client V2, the function CompareAndSwap will erase the expiration time of the key.
E.g
rawClient.PutWithTTL key1 value1 100
//GetKeyTTL key1 ->*ttl ==100
oldValue :=rawClient.Get key1
previousValue, ok, err := rawClient.CompareAndSwap key1 oldValue newValue
//GetKeyTTL key1 ->*ttl == 0
As far as I know, tikv splices ttl in value and uses it as a compaction filter to delete the key after the life cycle.
In tikv go-client, CompareAndSwap does not specify Ttl
reqArgs := kvrpcpb.RawCASRequest{
Key: key,
Value: newValue,
}
if previousValue == nil {
reqArgs.PreviousNotExist = true
} else {
reqArgs.PreviousValue = previousValue
}
req := tikvrpc.NewRequest(tikvrpc.CmdRawCompareAndSwap, &reqArgs)
req.MaxExecutionDurationMs = uint64(client.MaxWriteExecutionTime.Milliseconds())
resp, _, err := c.sendReq(ctx, key, req, false)
Can I add new ttl to RawCASRequest? Also what can be done to update the value using CAS and keep the historical ttl?@iosmanthus
hi, I raise a PR #943 to fix this. @iosmanthus