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

Support Green GC #13926

Merged
merged 26 commits into from Jan 10, 2020
Merged

Support Green GC #13926

merged 26 commits into from Jan 10, 2020

Conversation

MyonKeminta
Copy link
Contributor

@MyonKeminta MyonKeminta commented Dec 5, 2019

What problem does this PR solve?

This PR implements Green GC, which changed the procedure of resolvelocks phase of GC, and allows TiKV to scan locks without getting each region's snapshot.

By default this feature is not enabled, and the configuration is hidden. Before enabling it, there should be more stability tests. There's also a known issue that it will cause too much memory.

What is changed and how it works?

The main changes are on TiKV side. TiDB just invokes the new APIs. Please refer to tikv/tikv#6138 for details.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

Code changes

  • None of those listed

Side effects

  • Increased code complexity

Related changes

  • Need to update the documentation
  • GC's document need to be updated
  • Need to update the tidb-ansible repository
  • Maybe more metrics

Release note

  • Required

Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
@MyonKeminta
Copy link
Contributor Author

/rebuild

Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
@@ -331,6 +331,18 @@ func (s *mockTikvGrpcServer) RawBatchScan(context.Context, *kvrpcpb.RawBatchScan
func (s *mockTikvGrpcServer) UnsafeDestroyRange(context.Context, *kvrpcpb.UnsafeDestroyRangeRequest) (*kvrpcpb.UnsafeDestroyRangeResponse, error) {
return nil, errors.New("unreachable")
}
func (s *mockTikvGrpcServer) RegisterLockObserver(context.Context, *kvrpcpb.RegisterLockObserverRequest) (*kvrpcpb.RegisterLockObserverResponse, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer to compound the service interface into mockTikvGrpcServer struct directly avoid these boilerplate code.
e.g

type mockTikvGrpcServer struct {TiKVService}

and remove all unreachable methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's not very proper to do it in this PR.

Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
@sre-bot
Copy link
Contributor

sre-bot commented Jan 6, 2020

@MyonKeminta, please update your pull request.

@MyonKeminta MyonKeminta changed the title [DNM] Support Green GC Support Green GC Jan 9, 2020
@MyonKeminta
Copy link
Contributor Author

/run-unit-test

Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>

err = w.removeLockObservers(ctx, safePoint, stores)
if err != nil {
return errors.Trace(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

If remove observer fails, we can still omit the traditional way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It already is because removeLockObserver never returns error... I've removed the return value

Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
for _, lock := range locks {
if loc.Contains(lock.Key) {
locksInRegion = append(locksInRegion, lock)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

should we break if it doesn't contain key?

func (s *mergeLockScanner) GetSucceededStores() map[uint64]interface{} {
stores := make(map[uint64]interface{})
for _, receiver := range s.receivers {
if receiver.Err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

If receiver has error, I think we should treat it just as an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did you mean returning an error? Here our solution is, for unsuccessful stores, GetSucceededStores doesn't return it and it will be scanned in next retry. The error is just logged.

Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Copy link
Contributor

@sticnarf sticnarf left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Contributor

@youjiali1995 youjiali1995 left a comment

Choose a reason for hiding this comment

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

LGTM. But I think it needs more comments.

@youjiali1995
Copy link
Contributor

/merge

@sre-bot sre-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jan 10, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Jan 10, 2020

/run-all-tests

@sre-bot sre-bot merged commit 8c3ee37 into pingcap:master Jan 10, 2020
@MyonKeminta MyonKeminta deleted the misono/green-gc branch January 10, 2020 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/GC status/can-merge Indicates a PR has been approved by a committer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants