-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
config, sysvar: move configs tmp-storage-* to instance sysvars #36849
base: master
Are you sure you want to change the base?
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Code Coverage Details: https://codecov.io/github/pingcap/tidb/commit/3984f5887b9e6e83c0f0d97b0ff385034b44645a |
/cc wshwsh12 |
/run-mysql-test |
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
@CbcWestwolf: 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. |
@CbcWestwolf: The following test failed, say
Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
@CbcWestwolf: The following tests failed, say
Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
What problem does this PR solve?
Issue Number: ref #34960
Problem Summary:
Before, if we want to change the temporary storage path/quota in a node/instance, we have to change the configuration and restart the node.
What is changed and how it works?
In this PR we introduce two instance scope variables
tmpdir
andtidb_tmp_storage_quota
, and the corresponding config items in[instance]
section.Check List
Tests
Manual Test
Data preparation
Setup
t1
andt2
:Test
There are several functions using
tmpdir
:util/disk/tempDir.go: InitializeTempDir()
would be called each time tmpdir is modified, and create a_dir.lock
file. We expect to see this file after we modify tmpdir.You can just switch different
tmpdir
likeTestSwitchMultipleTmpDir
, and check that both$tmpdir/record/
and$tmpdir/_dir.lock
exist.executor/explain.go: getHeapProfile()
would create a temp file named like$tmpdir/record/heapGC2006-01-02T15:04:05Z07:001
. We can use the sqlexplain analyze select ...
to trigger a long-time query and modify [instance].tmpdir in another session. We expect that the modification is successful and the origin heap file names are recorded inmemoryDebugModeHandler.infoField
and shown on logs.set global tmpdir = 'another_tmpdir';
explain analyze
in session 1 to finish. The log would show a line containing["Memory Debug Mode"] [sql=finished]
. In this line you could seeheap profile
following thetmpdir
. In most cases it has been set toanother_tmpdir
, but it is still reasonable if it keeps the origin value.util/misc.go: LoadTLSCertificates()
creates a key file and certificate in tmpdir. We can setauto-tls
totrue
inconfig.toml
and use the sqlalter instance reload tls
to callLoadTLSCertificates()
. By checking the log, we expect that the paths of cert and key file keep the same as the original.config.toml
as below and start the tidb:select @@ssl_key, @@ssl_cert;
alter instance reload tls;
, and the log["execute reload tls"]
shows the ssl_key and ssl_pathselect @@ssl_key, @@ssl_cert;
and we expect to get the origin resultutil/chunk/disk.go: initDiskFile()
usesdisk.TmpDirMutex
to prevent possible conflicts since it has several statements reading tmpdir. We can perform a large query withsort
orjoin
operator under limited memory to call this method. Since the block of mutex, the modification of tmpdir would wait for the query finished.chunk.ListInDisk-xxxxx
andchunk.ListInDiskOffset-xxxxx
exists on tmpdir:set global tmpdir = "another_tmpdir";
in session 2chunk
files are deleted, andselect @@global.tmpdir;
returnsanother_tmpdir
in session 1.type memoryUsageAlarm struct
binds to each domain, and owns atmpDir
field for dumping information about OOM. We can modifytidb_memory_usage_alarm_ratio
to trigger the alarm dumping.config.toml
as below and start the tidb:select t1.c as c1, t2.c as c2 from t1 join t2 on t1.c = t2.c - t1.c order by c2 desc;
ddl/ingest/env.go: genLightningDataDir()
is called each time a ddl is starting. We expect to see a directory named$tmpdir/tmp_ddl-<port>
after we modify the tmpdir and do another ddl.Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.