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

[WIP] Set tidb_gc_life_time by sysvar #3922

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

shonge
Copy link
Member

@shonge shonge commented Apr 15, 2021

What problem does this PR solve?

Close #3868
Close #3649

Dependency #3900

What is changed and how does it work?

Add TidbGCVariable = "tidb_gc_life_time" and move TikvGCVariable = "tikv_gc_life_time" to LegacyTikvGCVariable = "tikv_gc_life_time".
Use SHOW GLOBAL VARIABLES LIKE tidb_gc_life_time to check if tidb support tidb_gc_life_time.
If support ,we use 'SET GLOBAL tidb_gc_life_time= 72h' to set GC life time, else using update mysql.tidb set variable_value = 72h where variable_name = tikv_gc_life_time.

Code changes

  • Has Go code change
  • Has CI related scripts change

Tests

  • Unit test
  • E2E test
  • Manual test
  • No code

Side effects

  • Breaking backward compatibility
  • Other side effects:

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Release Notes

Please refer to Release Notes Language Style Guide before writing the release note.

Set tidb_gc_life_time by sysvar

@shonge shonge changed the title set tidb_gc_life_time by sysvar [WIP]set tidb_gc_life_time by sysvar Apr 15, 2021
@codecov-io
Copy link

Codecov Report

Merging #3922 (549d560) into master (b5e3ee5) will decrease coverage by 5.46%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #3922      +/-   ##
==========================================
- Coverage   67.88%   62.41%   -5.47%     
==========================================
  Files         175      171       -4     
  Lines       18618    18133     -485     
==========================================
- Hits        12638    11318    -1320     
- Misses       4879     5717     +838     
+ Partials     1101     1098       -3     
Flag Coverage Δ
e2e ?
unittest 62.41% <0.00%> (ø)

@shonge shonge changed the title [WIP]set tidb_gc_life_time by sysvar Set tidb_gc_life_time by sysvar Apr 16, 2021
cmd/backup-manager/app/constants/constants.go Outdated Show resolved Hide resolved
cmd/backup-manager/app/util/generic.go Outdated Show resolved Hide resolved
cmd/backup-manager/app/util/generic.go Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Apr 22, 2021

Codecov Report

Merging #3922 (717c6ee) into master (6f1f091) will increase coverage by 0.92%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #3922      +/-   ##
==========================================
+ Coverage   67.79%   68.72%   +0.92%     
==========================================
  Files         177      177              
  Lines       18840    18866      +26     
==========================================
+ Hits        12773    12965     +192     
+ Misses       4945     4772     -173     
- Partials     1122     1129       +7     
Flag Coverage Δ
e2e 43.72% <ø> (+2.59%) ⬆️
unittest 61.93% <0.00%> (-0.09%) ⬇️

@shonge shonge force-pushed the update_set_tikv_gc_life_time branch from 4df7e17 to b056113 Compare April 23, 2021 08:29
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • july2993

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.

@shonge
Copy link
Member Author

shonge commented Apr 26, 2021

/test pull-e2e-kind-serial


func (bo *GenericOptions) HasTiDBGCLifeTime(ctx context.Context, db *sql.DB) (bool, error) {
var tikvGCTime string
sql := fmt.Sprintln("SHOW GLOBAL VARIABLES LIKE ?")
Copy link
Member

Choose a reason for hiding this comment

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

no need to use fmt.Sprintln here, right?

if err != nil {
return false, fmt.Errorf("query cluster %s %s failed, sql: %s, err: %v", bo, constants.TidbGCVariable, sql, err)
}
if len(tikvGCTime) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

you may use sql.NullString for judgment here?

if err != nil {
return tikvGCTime, fmt.Errorf("query cluster %s %s failed, sql: %s, err: %v", bo, constants.TikvGCVariable, sql, err)
return tikvGCTime, fmt.Errorf("query cluster %s %s failed, sql: %s, err: %v", bo, constants.TidbGCVariable, sql, err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return tikvGCTime, fmt.Errorf("query cluster %s %s failed, sql: %s, err: %v", bo, constants.TidbGCVariable, sql, err)
return tikvGCTime, fmt.Errorf("query cluster %s %s failed, sql: %s, err: %v", bo, gcVariable, sql, err)

if err != nil {
return fmt.Errorf("set cluster %s %s failed, sql: %s, err: %v", bo, constants.TikvGCVariable, sql, err)
return fmt.Errorf("set cluster %s %s failed, sql: %s, err: %v", bo, constants.TidbGCVariable, sql, err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("set cluster %s %s failed, sql: %s, err: %v", bo, constants.TidbGCVariable, sql, err)
return fmt.Errorf("set cluster %s %s failed, sql: %s, err: %v", bo, gcVariable, sql, err)

@DanielZhangQD
Copy link
Contributor

@shonge Could you please add the test result for the below cases:

  • Backup with Dumpling with v4.0.12
  • Backup with Dumpling with v5.0.0
  • Backup with BR with v4.0.12
  • Backup with BR with v5.0.0
  • Restore with BR with v4.0.12
  • Restore with BR with v5.0.0

@DanielZhangQD DanielZhangQD changed the title Set tidb_gc_life_time by sysvar [WIP] Set tidb_gc_life_time by sysvar May 13, 2021
@ti-chi-bot
Copy link
Member

@shonge: 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
Projects
None yet
7 participants