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

new_owner: implement gc manager #1819

Merged
merged 7 commits into from
May 26, 2021

Conversation

zier-one
Copy link
Contributor

What problem does this PR solve?

GC manager: a module of the new owner, which reports the min checkpoint ts to PD GC service and checks the changefeed which of checkpoint ts is behind too far to stop

Check List

Tests

  • Unit test

Release note

  • No release note

@ti-chi-bot ti-chi-bot requested review from amyangfei and overvenus May 24, 2021 01:21
@ti-chi-bot ti-chi-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label May 24, 2021
@zier-one zier-one added needs-cherry-pick-release-4.0 Should cherry pick this PR to release-4.0 branch. needs-cherry-pick-release-5.0 Should cherry pick this PR to release-5.0 branch. status/ptal Could you please take a look? labels May 24, 2021
cdc/owner/gc_manager.go Outdated Show resolved Hide resolved
cdc/owner/gc_manager.go Outdated Show resolved Hide resolved
switch cfState.Info.State {
case model.StateNormal, model.StateStopped, model.StateError:
default:
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a debug log here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no need to log this, i think

Copy link
Member

Choose a reason for hiding this comment

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

Why do we need a log? @liuzix
And why not? @leoppro

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because there is no need to keep a log here, for no particular reason.

Copy link
Contributor

Choose a reason for hiding this comment

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

My thought was that we could use some log to debug the calculation of gcSafePoint in case of unexpected behavior. But on second thought, the log might produce too many lines and it might not be that useful. So NVM.

cdc/owner/gc_manager.go Show resolved Hide resolved
cdc/owner/gc_manager.go Outdated Show resolved Hide resolved
return m.pdTimeCached, nil
}

func (m *gcManager) CheckTsTooFarBehindToStop(ctx cdcContext.Context, checkpointTs model.Ts) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

This check is not used, will it be used in another PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it used by changefeed

}
minCheckpointTs := uint64(math.MaxUint64)
for _, cfState := range state.Changefeeds {
if cfState.Info == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

just curious, if ChangefeedReactorState.ChangeFeedInfo==nil, is it a valid state?

Copy link
Contributor Author

@zier-one zier-one May 25, 2021

Choose a reason for hiding this comment

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

no, it's not a valid state

switch cfState.Info.State {
case model.StateNormal, model.StateStopped, model.StateError:
default:
continue
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need a log? @liuzix
And why not? @leoppro

@@ -45,6 +45,7 @@ type FeedState string
// All FeedStates
const (
StateNormal FeedState = "normal"
StateError FeedState = "error"
Copy link
Member

Choose a reason for hiding this comment

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

By adding a new state, does it cause compatibility issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, it will not cause compatibility issues.

Comment on lines +53 to +55
failpoint.Inject("InjectGcSafepointUpdateInterval", func(val failpoint.Value) {
gcSafepointUpdateInterval = time.Duration(val.(int) * int(time.Millisecond))
})
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need a failpoint? And why does it change a global variable inside a function?

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's port from the old owner, and this failpoint is already used by some test cases

if err != nil {
return errors.Trace(err)
}
if checkpointTs < m.lastSafePointTs || pdTime.Sub(oracle.GetTimeFromTS(checkpointTs)) > time.Duration(m.gcTTL)*time.Second {
Copy link
Member

Choose a reason for hiding this comment

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

What will happen when we create a changefeed with a start ts x where gc safepoint is x-48h and gcTTL is 24h?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the owner will stop the changefeed and set the feed state to failed

@amyangfei
Copy link
Contributor

/lgtm

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 25, 2021
@liuzix
Copy link
Contributor

liuzix commented May 26, 2021

/lgtm

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • amyangfei
  • liuzix

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 writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels May 26, 2021
@zier-one
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 0a9f145

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 26, 2021
@zier-one
Copy link
Contributor Author

/run-integration-tests

@zier-one
Copy link
Contributor Author

/run-kafka-tests

@zier-one
Copy link
Contributor Author

/run-integration-tests

@zier-one
Copy link
Contributor Author

/run-kafka-tests

@zier-one
Copy link
Contributor Author

/run-integration-tests

1 similar comment
@zier-one
Copy link
Contributor Author

/run-integration-tests

@zier-one
Copy link
Contributor Author

/run-integration-tests

@codecov-commenter
Copy link

Codecov Report

Merging #1819 (924f241) into master (99ee8fb) will increase coverage by 0.2147%.
The diff coverage is 56.8493%.

@@               Coverage Diff                @@
##             master      #1819        +/-   ##
================================================
+ Coverage   53.4083%   53.6231%   +0.2147%     
================================================
  Files           154        157         +3     
  Lines         16166      16312       +146     
================================================
+ Hits           8634       8747       +113     
- Misses         6608       6618        +10     
- Partials        924        947        +23     

@ti-chi-bot ti-chi-bot merged commit e0e98b7 into pingcap:master May 26, 2021
@zier-one zier-one deleted the new_owner_gc_manager branch May 26, 2021 07:17
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #1841.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #1842.

zier-one pushed a commit to zier-one/ticdc that referenced this pull request Jun 17, 2021
zier-one pushed a commit to zier-one/ticdc that referenced this pull request Jun 22, 2021
zier-one pushed a commit to zier-one/ticdc that referenced this pull request Jun 22, 2021
zier-one pushed a commit to zier-one/ticdc that referenced this pull request Jun 22, 2021
zier-one pushed a commit to zier-one/ticdc that referenced this pull request Jun 22, 2021
zier-one pushed a commit to zier-one/ticdc that referenced this pull request Jun 22, 2021
ti-chi-bot pushed a commit that referenced this pull request Jun 22, 2021
ti-chi-bot pushed a commit that referenced this pull request Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-4.0 Should cherry pick this PR to release-4.0 branch. needs-cherry-pick-release-5.0 Should cherry pick this PR to release-5.0 branch. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. status/ptal Could you please take a look?
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants