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

variable: support tidb_schema_cache_size reasonable range #54035

Merged
merged 10 commits into from
Jun 26, 2024

Conversation

lilinghai
Copy link
Contributor

@lilinghai lilinghai commented Jun 14, 2024

What problem does this PR solve?

Issue Number: close #54034

Problem Summary:

What changed and how does it work?

The value range is 0 and [536870912, 9223372036854775807] in bytes. The size format with the units "KB|MB|GB|TB" is supported.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Signed-off-by: lilinghai <lilinghai@pingcap.com>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 14, 2024
Copy link

tiprow bot commented Jun 14, 2024

Hi @lilinghai. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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-sigs/prow repository.

Copy link

codecov bot commented Jun 14, 2024

Codecov Report

Attention: Patch coverage is 91.66667% with 3 lines in your changes missing coverage. Please review.

Project coverage is 56.2965%. Comparing base (1368bf7) to head (646b75e).
Report is 20 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54035         +/-   ##
=================================================
- Coverage   72.8706%   56.2965%   -16.5742%     
=================================================
  Files          1521       1643        +122     
  Lines        435164     613659     +178495     
=================================================
+ Hits         317107     345469      +28362     
- Misses        98499     245061     +146562     
- Partials      19558      23129       +3571     
Flag Coverage Δ
integration 36.9929% <66.6666%> (?)
unit 72.0672% <91.6666%> (+0.2001%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.9656% <ø> (ø)
parser ∅ <ø> (∅)
br 52.3741% <ø> (+6.2353%) ⬆️

Signed-off-by: lilinghai <lilinghai@pingcap.com>
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 14, 2024
@lilinghai
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Jun 14, 2024

@lilinghai: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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-sigs/prow repository.

@lilinghai lilinghai changed the title variable: fix tidb_schema_cache_size range max value variable: support tidb_schema_cache_size reasonable range Jun 15, 2024
Signed-off-by: lilinghai <lilinghai@pingcap.com>
require.Equal(t, schemaCacheSize.Value, strconv.Itoa(DefTiDBSchemaCacheSize))

// MinValue is 512 MB
err = mock.SetGlobalSysVar(context.Background(), TiDBSchemaCacheSize, strconv.FormatUint(100*mb, 10))
Copy link
Member

Choose a reason for hiding this comment

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

Please test 512MB-1 and MaxValue + 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@@ -1595,7 +1596,8 @@ var (
IgnoreInlistPlanDigest = atomic.NewBool(DefTiDBIgnoreInlistPlanDigest)
TxnEntrySizeLimit = atomic.NewUint64(DefTiDBTxnEntrySizeLimit)

SchemaCacheSize = atomic.NewInt64(DefTiDBSchemaCacheSize)
SchemaCacheSize = atomic.NewUint64(DefTiDBSchemaCacheSize)
SchemaCacheSizeOriginText = atomic.NewString(strconv.Itoa(DefTiDBSchemaCacheSize))
Copy link
Member

Choose a reason for hiding this comment

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

We can get the text from SchemaCacheSize like we have done for TiDBServerMemoryLimitSessMinSize

Copy link
Contributor Author

@lilinghai lilinghai Jun 24, 2024

Choose a reason for hiding this comment

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

This value is used to store the content set by the user. For example, if the user sets 1GB, then the display for user queries will also be 1GB, not 1,073,741,824. However, the TiDBServerMemoryLimitSessMinSize will display the value as an integer to the user.

mysql> set @@global.tidb_server_memory_limit_sess_min_size='1GB';
Query OK, 0 rows affected (0.01 sec)

mysql> select @@global.tidb_server_memory_limit_sess_min_size;
+-------------------------------------------------+
| @@global.tidb_server_memory_limit_sess_min_size |
+-------------------------------------------------+
| 1073741824                                      |
+-------------------------------------------------+
1 row in set (0.00 sec)

mysql> set @@global.tidb_schema_cache_size='1GB';
Query OK, 0 rows affected (0.00 sec)

mysql> select @@global.tidb_schema_cache_size;
+---------------------------------+
| @@global.tidb_schema_cache_size |
+---------------------------------+
| 1GB                             |
+---------------------------------+
1 row in set (0.00 sec)

simlar to tidb_server_memory_limit

mysql> set @@global.tidb_server_memory_limit='1GB';
Query OK, 0 rows affected (0.06 sec)

mysql> select @@global.tidb_server_memory_limit;
+-----------------------------------+
| @@global.tidb_server_memory_limit |
+-----------------------------------+
| 1GB                               |
+-----------------------------------+
1 row in set (0.00 sec)

Signed-off-by: lilinghai <lilinghai@pingcap.com>
Signed-off-by: lilinghai <lilinghai@pingcap.com>
@lilinghai
Copy link
Contributor Author

/test unit-test

Copy link

tiprow bot commented Jun 24, 2024

@lilinghai: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test unit-test

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-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 25, 2024
Signed-off-by: lilinghai <lilinghai@pingcap.com>
Signed-off-by: lilinghai <lilinghai@pingcap.com>
pkg/infoschema/infoschema_test.go Show resolved Hide resolved
pkg/sessionctx/variable/varsutil.go Show resolved Hide resolved
pkg/sessionctx/variable/varsutil.go Show resolved Hide resolved
pkg/sessionctx/variable/varsutil.go Outdated Show resolved Hide resolved
Signed-off-by: lilinghai <lilinghai@pingcap.com>
Copy link
Contributor

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

pkg/sessionctx/variable/sysvar_test.go Show resolved Hide resolved
Signed-off-by: lilinghai <lilinghai@pingcap.com>
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 26, 2024
Copy link

ti-chi-bot bot commented Jun 26, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-25 02:40:16.188104697 +0000 UTC m=+687342.673593529: ☑️ agreed by wjhuang2016.
  • 2024-06-26 04:43:26.065479051 +0000 UTC m=+781132.550967884: ☑️ agreed by lance6716.

@easonn7
Copy link

easonn7 commented Jun 26, 2024

/approve

Copy link

ti-chi-bot bot commented Jun 26, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: easonn7, lance6716, wjhuang2016

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Jun 26, 2024
@ti-chi-bot ti-chi-bot bot merged commit 6b0db7f into pingcap:master Jun 26, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tidb_schema_cache_size max support value is wrong
4 participants