Description:
The variable_value length is set to 1024 in the performance_schema.global_variables table:
mysql [localhost:24991] {msandbox} ((none)) > show create table performance_schema.global_variables\G
*************************** 1. row ***************************
Table: global_variables
Create Table: CREATE TABLE `global_variables` (
`VARIABLE_NAME` varchar(64) NOT NULL,
`VARIABLE_VALUE` varchar(1024) DEFAULT NULL,
PRIMARY KEY (`VARIABLE_NAME`)
) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
1 row in set (0.00 sec)
There is no such limitation in the analogous variables, for instance for @@global.gtid_purged.
From the performance_schema table, we get:
mysql [localhost:24991] {msandbox} ((none)) > select * from performance_schema.global_variables where variable_name like '%purged%'\G
*************************** 1. row ***************************
VARIABLE_NAME: gtid_purged
VARIABLE_VALUE: 00024991-0000-0000-0000-000000024991:1-33,
000a2071-fbc5-4926-a238-2a3156340457:7844-62857222,
015b7f7b-ce69-4345-815d-91c5884d3248:5427-105339874,
031ecb6d-ce7d-4bb0-8586-da00b7379199:2344-90277507,
039c5d09-bfc1-474b-9414-82633c3a7fd1:7330-72158588,
03aac17e-265c-4481-9637-dfb3fd259bd8:5662-105368485,
0741b25b-be67-4948-beb0-ccb6c5920a36:7237-23265489,
0ccd388d-4edd-4c8e-a011-8611020dc0e9:5350-69299846,
0d3e1ddc-260f-423a-9880-0cac851c678e:11763-69898222,
0f5676df-a371-4fa2-bee2-887de8acd2b7:1845-37551943,
107f154f-3be6-494b-8434-1d32f771252b:11595-40768437,
117d27cf-74d2-44a1-b623-1b9583f18e25:2725-87126730,
16aba989-c12d-4fba-a6f9-ffd1cfb37cd0:2006-9121709,
1783650e-c87e-4473-9ef9-389eb37d940b:2166-27874787,
18b51c20-d73b-4e2f-afe5-15fe1b80d0f8:7644-84587478,
204b95c8-6260-48a9-a1a9-1000e9aabc1c:5770-83582139,
206383ea-9271-4811-bc55-da8c8880399b:457-89412644,
232b3c1c-be69-4a96-afca-8953baf13f5a:4319-109952857,
25c01ec2-5938-4249-be7c-6399b04869d8:11871-90066097,
266a72cc-a532-4f9c-9633-027969a880cd:500-
1 row in set (0.00 sec)
From the variable itself, we get:
mysql [localhost:24991] {msandbox} ((none)) > select @@global.'gtid_purged'\G
*************************** 1. row ***************************
@@global.'gtid_purged': 00024991-0000-0000-0000-000000024991:1-33,
000a2071-fbc5-4926-a238-2a3156340457:7844-62857222,
015b7f7b-ce69-4345-815d-91c5884d3248:5427-105339874,
031ecb6d-ce7d-4bb0-8586-da00b7379199:2344-90277507,
039c5d09-bfc1-474b-9414-82633c3a7fd1:7330-72158588,
03aac17e-265c-4481-9637-dfb3fd259bd8:5662-105368485,
0741b25b-be67-4948-beb0-ccb6c5920a36:7237-23265489,
0ccd388d-4edd-4c8e-a011-8611020dc0e9:5350-69299846,
0d3e1ddc-260f-423a-9880-0cac851c678e:11763-69898222,
0f5676df-a371-4fa2-bee2-887de8acd2b7:1845-37551943,
107f154f-3be6-494b-8434-1d32f771252b:11595-40768437,
117d27cf-74d2-44a1-b623-1b9583f18e25:2725-87126730,
16aba989-c12d-4fba-a6f9-ffd1cfb37cd0:2006-9121709,
1783650e-c87e-4473-9ef9-389eb37d940b:2166-27874787,
18b51c20-d73b-4e2f-afe5-15fe1b80d0f8:7644-84587478,
204b95c8-6260-48a9-a1a9-1000e9aabc1c:5770-83582139,
206383ea-9271-4811-bc55-da8c8880399b:457-89412644,
232b3c1c-be69-4a96-afca-8953baf13f5a:4319-109952857,
25c01ec2-5938-4249-be7c-6399b04869d8:11871-90066097,
266a72cc-a532-4f9c-9633-027969a880cd:500-62995915, <--- last (and partial) entry shown above
2a303f9a-445e-4c6e-924b-b246cc4312be:5417-55703962,
2c989e19-bcf4-4f46-95b0-e755fd600847:1572-9195641
1 row in set (0.00 sec)
Tested on latest version:
mysql [localhost:24991] {msandbox} ((none)) > show variables like '%version%';
+--------------------------+------------------------------+
| Variable_name | Value |
+--------------------------+------------------------------+
...
| version | 8.0.28 |
| version_comment | MySQL Community Server - GPL |
| version_compile_machine | x86_64 |
| version_compile_os | Linux |
| version_compile_zlib | 1.2.11 |
+--------------------------+------------------------------+
13 rows in set (0.01 sec)
How to repeat:
The easy way of reproducing is to manually set the gtid_purged value to some artificial string, that exceeds 1024 chars. This can happen in a real case scenario, too, without the need of manual intervention.
To repeat easily:
mysql [localhost:24991] {msandbox} ((none)) > reset master;
Query OK, 0 rows affected (0.01 sec)
mysql [localhost:24991] {msandbox} ((none)) > set global GTID_PURGED="00024991-0000-0000-0000-000000024991:1-33,
"> 000a2071-fbc5-4926-a238-2a3156340457:7844-62857222,
"> 015b7f7b-ce69-4345-815d-91c5884d3248:5427-105339874,
"> 031ecb6d-ce7d-4bb0-8586-da00b7379199:2344-90277507,
"> 039c5d09-bfc1-474b-9414-82633c3a7fd1:7330-72158588,
"> 03aac17e-265c-4481-9637-dfb3fd259bd8:5662-105368485,
"> 0741b25b-be67-4948-beb0-ccb6c5920a36:7237-23265489,
"> 0ccd388d-4edd-4c8e-a011-8611020dc0e9:5350-69299846,
"> 0d3e1ddc-260f-423a-9880-0cac851c678e:11763-69898222,
"> 0f5676df-a371-4fa2-bee2-887de8acd2b7:1845-37551943,
"> 107f154f-3be6-494b-8434-1d32f771252b:11595-40768437,
"> 117d27cf-74d2-44a1-b623-1b9583f18e25:2725-87126730,
"> 16aba989-c12d-4fba-a6f9-ffd1cfb37cd0:2006-9121709,
"> 1783650e-c87e-4473-9ef9-389eb37d940b:2166-27874787,
"> 18b51c20-d73b-4e2f-afe5-15fe1b80d0f8:7644-84587478,
"> 204b95c8-6260-48a9-a1a9-1000e9aabc1c:5770-83582139,
"> 206383ea-9271-4811-bc55-da8c8880399b:457-89412644,
"> 232b3c1c-be69-4a96-afca-8953baf13f5a:4319-109952857,
"> 25c01ec2-5938-4249-be7c-6399b04869d8:11871-90066097,
"> 266a72cc-a532-4f9c-9633-027969a880cd:500-62995915,
"> 2a303f9a-445e-4c6e-924b-b246cc4312be:5417-55703962,
"> 2c989e19-bcf4-4f46-95b0-e755fd600847:1572-9195641";
Query OK, 0 rows affected (0.00 sec)
And then issue the SELECT queries above, to see the difference.
Suggested fix:
Either change the datatype to support the maximum length allowed in variables, or document these issues, and the expected way of working around them.