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

function RawCAS do not expose parameter 'ttl' #371

Open
tutububug opened this issue Nov 11, 2021 · 7 comments · May be fixed by #1198
Open

function RawCAS do not expose parameter 'ttl' #371

tutububug opened this issue Nov 11, 2021 · 7 comments · May be fixed by #1198

Comments

@tutububug
Copy link

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.

@disksing
Copy link
Collaborator

Thanks @tutububug I think it is a good idea.
We may need your opinion /cc @iosmanthus

@iosmanthus
Copy link
Member

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.

@dbjoa
Copy link

dbjoa commented Feb 22, 2022

@iosmanthus
Do you have any update for the issue?

@iosmanthus
Copy link
Member

@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.

@tutububug
Copy link
Author

tutububug commented Feb 24, 2022 via email

@wenlive
Copy link

wenlive commented Oct 13, 2022

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

@tutububug
Copy link
Author

tutububug commented Aug 15, 2023

hi, I raise a PR #943 to fix this. @iosmanthus

@Smityz Smityz linked a pull request Feb 29, 2024 that will close this issue
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 a pull request may close this issue.

5 participants