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

*: adjust delta schema count and add metrics #11625

Merged
merged 11 commits into from
Sep 27, 2019

Conversation

zimulala
Copy link
Contributor

@zimulala zimulala commented Aug 5, 2019

What problem does this PR solve?

The original size of deltaSchemaInfos is 100.
Executing some SQLs may take a long time. At the same time, the TiDB cluster may do a lot of DDLs, which means we change a lot of schema versions. And the schema version changed in it may exceed 100. Then the SQLs will return the error of Information schema is changed..

If the DDL owner TiDB and the receiving request TiDB are on the same TiDB, it takes 50 + ms to update each mode version.
If the DDL owner TiDB and the receiving request TiDB aren't on the same TiDB, it takes 500 + ms to update each mode version.

The default of MaxTxnTimeUse is 590s. So I set the size of deltaSchemaInfos to 1024.

What is changed and how it works?

  • Add a variable of TiDBMaxDeltaSchemaCount to update the max size of deltaSchemaInfos . Besides, add a function of merge

  • Add some metrics.

Check List

Tests

  • Unit test

Related changes

  • Need to cherry-pick to the release branch

@codecov
Copy link

codecov bot commented Aug 5, 2019

Codecov Report

Merging #11625 into master will decrease coverage by 0.0725%.
The diff coverage is 100%.

@@               Coverage Diff               @@
##             master    #11625        +/-   ##
===============================================
- Coverage   79.7436%   79.671%   -0.0726%     
===============================================
  Files           462       461         -1     
  Lines        102106    101461       -645     
===============================================
- Hits          81423     80835       -588     
- Misses        14799     14810        +11     
+ Partials       5884      5816        -68

@zimulala zimulala changed the title *: adjust detal schema count and add metrics *: adjust delta schema count and add metrics Aug 6, 2019
@winkyao
Copy link
Contributor

winkyao commented Aug 11, 2019

@zimulala Please fix ci

@zimulala
Copy link
Contributor Author

PTAL @winkyao @jackysp

domain/schema_validator.go Outdated Show resolved Hide resolved
@zimulala
Copy link
Contributor Author

PTAL @jackysp @winkyao

@zimulala
Copy link
Contributor Author

PTAL @tiancaiamao @jackysp @winkyao

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

屏幕快照 2019-08-23 下午7 38 15

There are still two files' permission changed.

@zimulala
Copy link
Contributor Author

zimulala commented Aug 26, 2019

PTAL @jackysp.

maxCnt := int(variable.GetMaxDetalSchemaCount())
if len(s.deltaSchemaInfos) > maxCnt && s.notMergeCnt > maxCnt/2 {
s.merge()
s.notMergeCnt = 1
Copy link
Member

Choose a reason for hiding this comment

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

Why set to 1 here? I think we don't know how many deltaSchemaInfos merged 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.

We call merge before setting the value. So I think that the previous deltaSchemaInfos have been merged.

@zimulala
Copy link
Contributor Author

PTAL @jackysp @tiancaiamao @winkyao

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

LGTM

@zimulala zimulala added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 30, 2019
@zimulala
Copy link
Contributor Author

PTAL @tiancaiamao @winkyao

domain/schema_validator.go Outdated Show resolved Hide resolved
@zimulala
Copy link
Contributor Author

PTAL @bb7133
@jackysp @tiancaiamao Do you need to review again?

Copy link
Contributor

@crazycs520 crazycs520 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

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

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

Rest LGTM

domain/schema_validator.go Outdated Show resolved Hide resolved
@zimulala
Copy link
Contributor Author

PTAL @AilinKid @tiancaiamao

s.deltaSchemaInfos = s.deltaSchemaInfos[1:]
}
}

type ids []int64
Copy link
Contributor

Choose a reason for hiding this comment

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

Defined but not used?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, used in line 248

@tiancaiamao
Copy link
Contributor

LGTM

@tiancaiamao tiancaiamao added the status/can-merge Indicates a PR has been approved by a committer. label Sep 27, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Sep 27, 2019

/run-all-tests

@AilinKid
Copy link
Contributor

LGTM

@tiancaiamao tiancaiamao merged commit ba9d1ca into pingcap:master Sep 27, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Sep 27, 2019

cherry pick to release-2.1 failed

@sre-bot
Copy link
Contributor

sre-bot commented Sep 27, 2019

cherry pick to release-3.0 failed

@zimulala zimulala deleted the schema-cache branch September 27, 2019 12:38
zimulala added a commit to zimulala/tidb that referenced this pull request Sep 30, 2019
zimulala added a commit to zimulala/tidb that referenced this pull request Sep 30, 2019
zimulala added a commit to zimulala/tidb that referenced this pull request Oct 3, 2019
zimulala added a commit to zimulala/tidb that referenced this pull request Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/server status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants