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

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

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

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-tests-checked release-note-none 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 55.6084%. Comparing base (1368bf7) to head (646b75e).
Report is 16 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54035         +/-   ##
=================================================
- Coverage   72.8706%   55.6084%   -17.2623%     
=================================================
  Files          1521       1642        +121     
  Lines        435164     611587     +176423     
=================================================
+ Hits         317107     340094      +22987     
- Misses        98499     248238     +149739     
- Partials      19558      23255       +3697     
Flag Coverage Δ
integration 21.7193% <44.4444%> (?)
unit 71.7921% <91.6666%> (-0.0750%) ⬇️

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

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

@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 <[email protected]>
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 <[email protected]>
Signed-off-by: lilinghai <[email protected]>
@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.

Signed-off-by: lilinghai <[email protected]>
Signed-off-by: lilinghai <[email protected]>
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 <[email protected]>
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 <[email protected]>
Copy link

ti-chi-bot bot commented Jun 26, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lance6716, wjhuang2016
Once this PR has been reviewed and has the lgtm label, please assign yudongusa for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm release-note-none 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
3 participants