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

storage: Use etcd lease to manage safe point expiration #4984

Closed

Conversation

AmoebaProtozoa
Copy link
Contributor

@AmoebaProtozoa AmoebaProtozoa commented May 18, 2022

Signed-off-by: AmoebaProtozoa 8039876+AmoebaProtozoa@users.noreply.github.com

An enhancement to #4937 which manages expiration manually

What problem does this PR solve?

Use etcd Lease feature to manage service safe point life time
Add revision related storage functions
Issue Number: ref #4865
RFC: tikv/rfcs#90

What is changed and how does it work?

APIv2: Using ETCD Lease to manage service safe point expiration

Check List

Tests

  • Unit test

Code changes

Side effects
No

Release note

None

Signed-off-by: AmoebaProtozoa <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: AmoebaProtozoa <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: AmoebaProtozoa <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: AmoebaProtozoa <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: AmoebaProtozoa <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: AmoebaProtozoa <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has not been approved.

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the release-note The PR should write the release note. label May 18, 2022
}

func (kv *etcdKVBase) SaveWithTTL(key, value string, ttlSeconds int64) error {
leaseID, err := kv.GrantLease(ttlSeconds)
Copy link
Member

Choose a reason for hiding this comment

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

Could we use etcdutil.EtcdKVPutWithTTL(context.TODO(),kv.client,key,value,ttlSeconds) directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I was trying to put SaveWithTTL into a SlowLogTxn like other update methods for timeout and logging. But I guess that created more complexity.

Should we skip timeout / logging for this operation like other read methods?

@codecov
Copy link

codecov bot commented May 19, 2022

Codecov Report

Merging #4984 (bda31f4) into master (b100049) will decrease coverage by 0.25%.
The diff coverage is 52.08%.

❗ Current head bda31f4 differs from pull request most recent head ab98f7c. Consider uploading reports for the commit ab98f7c to get more accurate results

@@            Coverage Diff             @@
##           master    #4984      +/-   ##
==========================================
- Coverage   75.65%   75.40%   -0.26%     
==========================================
  Files         310      309       -1     
  Lines       30675    30544     -131     
==========================================
- Hits        23208    23032     -176     
- Misses       5463     5495      +32     
- Partials     2004     2017      +13     
Flag Coverage Δ
unittests 75.40% <52.08%> (-0.26%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
server/storage/kv/etcd_kv.go 69.56% <46.42%> (-10.15%) ⬇️
server/storage/endpoint/gc_key_space.go 68.83% <57.89%> (+2.16%) ⬆️
server/storage/endpoint/key_path.go 100.00% <100.00%> (ø)
pkg/errs/errs.go 75.00% <0.00%> (-25.00%) ⬇️
server/config/service_middleware_config.go 75.00% <0.00%> (-25.00%) ⬇️
server/api/service_middleware.go 68.18% <0.00%> (-16.64%) ⬇️
server/api/admin.go 50.87% <0.00%> (-16.57%) ⬇️
server/storage/endpoint/rule.go 83.33% <0.00%> (-11.12%) ⬇️
pkg/tempurl/tempurl.go 60.00% <0.00%> (-10.00%) ⬇️
server/gc/safepoint.go 84.61% <0.00%> (-7.98%) ⬇️
... and 42 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b100049...ab98f7c. Read the comment docs.

Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
@ti-chi-bot ti-chi-bot added release-note-none and removed release-note The PR should write the release note. labels May 27, 2022
@AmoebaProtozoa AmoebaProtozoa changed the title storage: Add APIs for RawKV GC using ETCD lease storage: Use ETCD lease to manage safe point expiration May 31, 2022
@AmoebaProtozoa AmoebaProtozoa changed the title storage: Use ETCD lease to manage safe point expiration storage: Use etcd lease to manage safe point expiration May 31, 2022
tests/client/go.sum Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
go.sum Outdated Show resolved Hide resolved
server/storage/endpoint/gc_key_space.go Outdated Show resolved Hide resolved
server/storage/kv/levedb_kv.go Outdated Show resolved Hide resolved
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
server/storage/endpoint/gc_key_space.go Outdated Show resolved Hide resolved
server/storage/kv/etcd_kv.go Outdated Show resolved Hide resolved
// Base is an abstract interface for load/save pd cluster data.
type Base interface {
Load(key string) (string, error)
LoadRange(key, endKey string, limit int) (keys []string, values []string, err error)
LoadRevision(key string) (string, int64, error)
Copy link
Member

Choose a reason for hiding this comment

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

revision here is a very specific term that is related to etcd, is there a better way to avoid introducing it in this generic KV interface?

Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 10, 2022
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
Signed-off-by: David <8039876+AmoebaProtozoa@users.noreply.github.com>
@ti-chi-bot ti-chi-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 21, 2022
@ti-chi-bot
Copy link
Member

@AmoebaProtozoa: PR needs rebase.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants