Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

checksum: use gc ttl api for checksum gc safepoint in v4.0 cluster #396

Merged
merged 13 commits into from
Oct 23, 2020

Conversation

glorv
Copy link
Contributor

@glorv glorv commented Sep 11, 2020

What problem does this PR solve?

close #389

What is changed and how it works?

Check List

Tests

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

Side effects

Related changes

@glorv glorv requested a review from kennytm September 11, 2020 09:01
@kennytm
Copy link
Collaborator

kennytm commented Sep 17, 2020

IIRC @overvenus suggested that the GC-TTL API cannot be used to affect the TiDB GC lifetime. Could you confirm with the TiDB team whether this change is effective? Thanks.

@overvenus
Copy link
Member

Confirmed with @MyonKeminta, service GC safe point (GC TTL) should resolve this problem.

@glorv glorv added this to the v4.0.8 milestone Oct 19, 2020
Copy link
Member

@overvenus overvenus left a comment

Choose a reason for hiding this comment

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

Please resolve conflicts and add a unit test.


// for v4.0.0 or upper, we can use the gc ttl api
var manager ChecksumManager
if pdVersion.Major >= 4 {
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember it's not all 4.0 version support gc-ttl...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

since v4.0.0.rc.1 pd has supported this interface, so I think this check is ok?


updateTick := time.NewTicker(updateGapTime)

_ = m.updateGCTTL(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

How about add a log for potential error?

return
case <-updateTick.C:
if err := m.updateGCTTL(ctx); err != nil {
log.L().Warn("failed to update service safe point, backup may fail if gc triggered",
Copy link
Contributor

Choose a reason for hiding this comment

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

backup?

Copy link
Contributor

@3pointer 3pointer 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 why not use one service ts point for checksum. not per table.

lightning only set service gc safepoint we run table checksum, currently approach only set gc safepoint when start checksum. So the safepoint should be always the newest. if lightning will run many hours, the safe point can be updated on time

Copy link
Contributor

@3pointer 3pointer left a comment

Choose a reason for hiding this comment

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

LGTM

@glorv
Copy link
Contributor Author

glorv commented Oct 23, 2020

/run-all-tests

@glorv glorv added the status/LGT1 One reviewer already commented LGTM (LGTM1) label Oct 23, 2020
Comment on lines 879 to 883
pdAddr := rc.cfg.TiDB.PdAddr
pdVersion, err := common.FetchPDVersion(rc.tls, pdAddr)
if err != nil {
return nil, errors.Trace(err)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

fetch PD version will fail when using "TiDB backend" outside of the cluster (i.e. the pd-addr is inaccessible).

you should return a no-op manager for TiDB backend instead of 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.

fixed, if checksum is not enabled, return nil instead

manager, ok := ctx.Value(&gcLifeTimeKey).(*gcLifeTimeManager)
if !ok {
return nil, errors.New("No gcLifeTimeManager found in context, check context initialization")
type ChecksumManager interface {
Copy link
Collaborator

@kennytm kennytm Oct 23, 2020

Choose a reason for hiding this comment

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

perhaps move these checksum managers into another file. this file is too large 😂

Copy link
Collaborator

@kennytm kennytm left a comment

Choose a reason for hiding this comment

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

LGTM

@3pointer 3pointer added status/LGT2 Two reviewers already commented LGTM, ready for merge (LGTM2) and removed status/LGT1 One reviewer already commented LGTM (LGTM1) labels Oct 23, 2020
@3pointer 3pointer merged commit aa83de1 into master Oct 23, 2020
@glorv glorv deleted the gc-ttl branch February 20, 2021 07:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status/LGT2 Two reviewers already commented LGTM, ready for merge (LGTM2)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use GC-TTL to keep the GC Lifetime
4 participants