File: persisted_variables.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (472 lines) | stat: -rw-r--r-- 16,465 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
# Save the initial number of concurrent sessions
--source include/count_sessions.inc

--echo #
--echo # WL#8688: Support ability to persist SET GLOBAL settings
--echo #

--echo # Syntax check for PERSIST option
SET PERSIST autocommit=0;
SET @@persist.max_execution_time=60000;
SET PERSIST max_user_connections=10, PERSIST max_allowed_packet=8388608;
SET @@persist.max_user_connections=10, PERSIST max_allowed_packet=8388608;
SET @@persist.max_user_connections=10, @@persist.max_allowed_packet=8388608;
SET PERSIST max_user_connections=10, @@persist.max_allowed_packet=8388608;

--echo # Syntax check for PERSIST/GLOBAL combination
SET PERSIST autocommit=0, GLOBAL max_user_connections=10;
SET @@persist.autocommit=0, @@global.max_user_connections=10;
SET GLOBAL autocommit=0, PERSIST max_user_connections=10;
SET @@global.autocommit=0, @@persist.max_user_connections=10;

--echo # Syntax check for PERSIST/SESSION combination
SET PERSIST autocommit=0, SESSION auto_increment_offset=10;
SET @@persist.autocommit=0, @@session.auto_increment_offset=10;
SET SESSION auto_increment_offset=20, PERSIST max_user_connections=10;
SET @@session.auto_increment_offset=20, @@persist.max_user_connections=10;
SET PERSIST autocommit=0, auto_increment_offset=10;
SET autocommit=0, PERSIST auto_increment_offset=10;

--echo # Syntax check for PERSIST/SESSION/GLOBAL combination
SET PERSIST autocommit=0, SESSION auto_increment_offset=10, GLOBAL max_error_count= 128;
SET SESSION autocommit=0, GLOBAL auto_increment_offset=10, PERSIST max_allowed_packet=8388608;
SET GLOBAL autocommit=0, PERSIST auto_increment_offset=10, SESSION max_error_count= 128;
SET @@persist.autocommit=0, @@session.auto_increment_offset=10, @@global.max_allowed_packet=8388608;
SET @@session.autocommit=0, @@global.auto_increment_offset=10, @@persist.max_allowed_packet=8388608;
SET @@global.autocommit=0, @@persist.auto_increment_offset=10, @@session.max_error_count= 128;

let $MYSQLD_DATADIR= `select @@datadir`;
--remove_file $MYSQLD_DATADIR/mysqld-auto.cnf

--echo # Restart server
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--echo # default values
SELECT @@global.max_connections;
SET PERSIST max_connections=33;

--echo # Restart server and check for values
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--echo # after restart
SELECT @@global.max_connections;

--echo # default values
SELECT @@global.sort_buffer_size;
SELECT @@global.max_heap_table_size;
SELECT @@global.replica_net_timeout;

--echo # persist few more variables
SET PERSIST sort_buffer_size=256000;
SET PERSIST max_heap_table_size=999424, replica_net_timeout=124;
SET PERSIST long_query_time= 8.3452;
SET PERSIST sql_require_primary_key= true;
SET PERSIST default_table_encryption= true;
SET PERSIST table_encryption_privilege_check= true;

--echo # Restart server
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--echo # after restart
SELECT @@global.max_connections;
SELECT @@global.sort_buffer_size;
SELECT @@global.max_heap_table_size;
SELECT @@global.replica_net_timeout;
SELECT @@global.long_query_time;
SELECT @@global.sql_require_primary_key;
SELECT @@global.default_table_encryption;
SELECT @@global.table_encryption_privilege_check;

--echo # modify existing persisted variables
SET PERSIST sort_buffer_size=156000,max_connections= 52;
SET PERSIST max_heap_table_size=887808, replica_net_timeout=160;
SET PERSIST long_query_time= 7.8102;
SET PERSIST sql_require_primary_key= false;
SET PERSIST default_table_encryption= false;
SET PERSIST table_encryption_privilege_check= false;

--echo # Restart server
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--echo # after restart
SELECT @@global.max_connections;
SELECT @@global.sort_buffer_size;
SELECT @@global.max_heap_table_size;
SELECT @@global.replica_net_timeout;
SELECT @@global.long_query_time;
SELECT @@global.sql_require_primary_key;
SELECT @@global.default_table_encryption;
SELECT @@global.table_encryption_privilege_check;

SELECT @@global.max_user_connections;
SELECT @@global.max_execution_time;

--echo # modify existing persisted variables and add new
SET PERSIST sort_buffer_size=256000;
SET PERSIST max_heap_table_size=999424, replica_net_timeout=124;
SET PERSIST long_query_time= 2.999999;
SET PERSIST sql_require_primary_key= true;
SET PERSIST default_table_encryption= true;
SET PERSIST table_encryption_privilege_check= true;
SET @@persist.max_execution_time=44000, @@persist.max_user_connections=30;

--echo # Restart server
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--echo # after restart
SELECT @@global.sort_buffer_size;
SELECT @@global.max_heap_table_size;
SELECT @@global.replica_net_timeout;
SELECT @@global.max_user_connections;
SELECT @@global.max_execution_time;
SELECT @@global.long_query_time;
SELECT @@global.sql_require_primary_key;
SELECT @@global.default_table_encryption;
SELECT @@global.table_encryption_privilege_check;

--echo # reset persisted variables
RESET PERSIST sort_buffer_size;
RESET PERSIST max_heap_table_size;
RESET PERSIST max_execution_time;
RESET PERSIST max_user_connections;
RESET PERSIST sql_require_primary_key;
RESET PERSIST default_table_encryption;
RESET PERSIST table_encryption_privilege_check;

--echo # Restart server
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--echo # after restart
SELECT @@global.sort_buffer_size;
SELECT @@global.max_heap_table_size;
SELECT @@global.replica_net_timeout;
SELECT @@global.max_user_connections;
SELECT @@global.max_execution_time;
SELECT @@global.max_connections;
SELECT @@global.server_id;
SELECT @@global.general_log;
SELECT @@global.concurrent_insert;
SELECT @@global.sql_require_primary_key;
SELECT @@global.default_table_encryption;
SELECT @@global.table_encryption_privilege_check;

--echo # reset persisted variables and add new
RESET PERSIST replica_net_timeout;
SET PERSIST server_id=47, @@persist.general_log=0;
SET PERSIST concurrent_insert=NEVER;
RESET PERSIST max_connections;

--echo # Restart server
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--echo # after restart
SELECT @@global.sort_buffer_size;
SELECT @@global.max_heap_table_size;
SELECT @@global.replica_net_timeout;
SELECT @@global.max_user_connections;
SELECT @@global.max_execution_time;
SELECT @@global.max_connections;
SELECT @@global.server_id;
SELECT @@global.general_log;
SELECT @@global.concurrent_insert;

--echo # check precedence with command line option
SELECT @@global.max_connections;
SELECT @@global.server_id;
SET PERSIST max_connections=88;
SET PERSIST server_id=9;
SET PERSIST session_track_system_variables='autocommit';

--echo # Restart server with command line option
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--exec echo "restart:--max_connections=55 --skip-networking --server-id=12 --session_track_system_variables="*"" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--echo # after restart must be 88,9, autocommit
SELECT @@global.max_connections;
SELECT @@global.server_id;
SELECT @@global.session_track_system_variables;

--echo
SELECT * FROM performance_schema.persisted_variables ORDER BY 1;
RESET PERSIST server_id;
RESET PERSIST general_log;
SET PERSIST max_connections=77;
SET PERSIST session_track_system_variables='max_connections';
SELECT * FROM performance_schema.persisted_variables ORDER BY 1;
--echo
SET PERSIST max_connections=99;
RESET PERSIST session_track_system_variables;
SET PERSIST concurrent_insert=ALWAYS;
SELECT * FROM performance_schema.persisted_variables ORDER BY 1;
--echo
RESET PERSIST max_connections;
SET PERSIST concurrent_insert=AUTO;
SELECT * FROM performance_schema.persisted_variables ORDER BY 1;
--echo

--remove_file $MYSQLD_DATADIR/mysqld-auto.cnf

--echo # negative tests persist session only variables
--error ER_LOCAL_VARIABLE
SET @@persist.sql_log_bin=0;

--echo # Test persisted-globals-load

# default is 1
SELECT @@global.persisted_globals_load;

--echo # New read-only variable persisted_globals_load.
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET PERSIST persisted_globals_load=0;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET GLOBAL  persisted_globals_load=ON;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET SESSION persisted_globals_load=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET GLOBAL persisted_globals_load= 'abc';
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET GLOBAL persisted_globals_load= -1;

--echo # Test persisted-globals-load functionality

SET PERSIST sort_buffer_size=256000;
SET PERSIST max_heap_table_size=999424, replica_net_timeout=124;

--echo # Restart server
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--echo # values must be read from persited config file
SELECT @@global.sort_buffer_size;
SELECT @@global.max_heap_table_size;
SELECT @@global.replica_net_timeout;

SELECT @@global.foreign_key_checks;
SET PERSIST foreign_key_checks=0;
SET PERSIST flush_time=2;

--echo # Restart server with persisted-globals-load=0
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--exec echo "restart:--persisted-globals-load=0" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--echo # should have default values
SELECT @@global.sort_buffer_size;
SELECT @@global.max_heap_table_size;
SELECT @@global.replica_net_timeout;

--echo # Expected value 1
SELECT @@global.foreign_key_checks;
--echo # Expected value 0
SELECT @@global.flush_time;
--echo # reset some persisted values
RESET PERSIST sort_buffer_size;
RESET PERSIST replica_net_timeout;

--echo # Restart server with persisted-globals-load=1
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--exec echo "restart:--persisted_globals_load=1" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--echo # should have default values
SELECT @@global.sort_buffer_size;
SELECT @@global.replica_net_timeout;
SELECT @@global.max_heap_table_size;
--echo # Expected value 0
SELECT @@global.foreign_key_checks;
--echo # Expected value 2
SELECT @@global.flush_time;

--remove_file $MYSQLD_DATADIR/mysqld-auto.cnf

call mtr.add_suppression("\\[Warning\\] \\[[^]]*\\] \\[[^]]*\\] option 'persisted_globals_load': boolean value 'NULL' was not recognized. Set to OFF.");
call mtr.add_suppression("\\[Warning\\] option 'persisted_globals_load': boolean value 'NULL' was not recognized. Set to OFF.");

--echo # Restart server with persisted-globals-load=NULL
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--exec echo "restart:--persisted-globals-load=NULL" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--let $file=$MYSQLTEST_VARDIR/log/mysqld.1.err
--echo # Should get warning in error log.
--let SEARCH_FILE=     $file
--let SEARCH_PATTERN=  persisted_globals_load
--source include/search_pattern.inc

SELECT @@global.persisted_globals_load;

--echo # Restart server with persisted-globals-load=1
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--echo #
--echo # Bug24569624: "SET PERSIST GENERAL_LOG=1" DOES NOT RESUME ON RESTART.
--echo #

SET PERSIST general_log=ON;
SET PERSIST autocommit= 0, innodb_deadlock_detect= OFF;
SET PERSIST enforce_gtid_consistency=ON;

SELECT @@global.general_log, @@global.autocommit,
       @@global.innodb_deadlock_detect, @@global.enforce_gtid_consistency;

--echo # Restart server
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

SELECT @@global.general_log, @@global.autocommit,
       @@global.innodb_deadlock_detect, @@global.enforce_gtid_consistency;

--echo #
--echo # Bug#24613005: SET PERSIST STORES PREVIOUS VALUE OF
--echo #               INNODB_BUFFER_POOL_SIZE TO MYSQLD-AUTO.CNF
--echo #

SELECT @@global.innodb_buffer_pool_size;
--remove_file $MYSQLD_DATADIR/mysqld-auto.cnf
SET PERSIST innodb_buffer_pool_size=10*1024*1024;
SELECT @@global.innodb_buffer_pool_size;

--echo # Restart server
--source include/restart_mysqld.inc

SELECT @@global.innodb_buffer_pool_size;
SELECT * FROM performance_schema.persisted_variables ORDER BY 1;
--echo

--echo #
--echo # Bug#26085712: SERVER FAILS TO START AFTER SET PERSIST GTID_MODE
--echo #                = ON_PERMISSIVE OR ON
--echo #

RESET PERSIST;
SELECT @@gtid_mode;
SET PERSIST gtid_mode=OFF_PERMISSIVE;
SET PERSIST gtid_mode=ON_PERMISSIVE;
SELECT @@gtid_mode;

--echo # Restart server and check for gtid_mode value
--source include/restart_mysqld.inc

SELECT @@gtid_mode;
RESET PERSIST;

--remove_file $MYSQLD_DATADIR/mysqld-auto.cnf

--echo # Restart server with all defaults
--source include/restart_mysqld.inc

--echo #
--echo # Bug #33417357: RESET PERSIST THROWS SYNTAX ERROR WITH COMPONENT SYSTEM VARIABLES
--echo #

--echo #
--echo # 1. test MyISAM Multiple Key Cache variables:
--echo #

SET PERSIST default.key_buffer_size = 1024*1024;
# Add reload tests after fixing a separate bug#33420306 "SET PERSIST fails with 2-component names of MyISAM Multiple Key Caches"
RESET PERSIST default.key_buffer_size;
SET GLOBAL default.key_buffer_size = DEFAULT;

--echo #
--echo # 2. test component-registered variable names:
--echo #

# int_sys_var.str_sys_var is duplicated in component_test_sys_var_service, this is expected.
call mtr.add_suppression("Duplicate variable name 'test_component.int_sys_var'");

INSTALL COMPONENT "file://component_test_sys_var_service";

SET PERSIST test_component.str_sys_var = 'test';

--source include/restart_mysqld.inc

--echo # Should return "test":
SELECT @@global.test_component.str_sys_var;
UNINSTALL COMPONENT "file://component_test_sys_var_service";

call mtr.add_suppression("Currently unknown variable 'test_component.str_sys_var' was read from the persisted config file");
--source include/restart_mysqld.inc

--error ER_UNKNOWN_SYSTEM_VARIABLE
SELECT @@global.test_component.str_sys_var;

INSTALL COMPONENT "file://component_test_sys_var_service";

--echo # Should return "test":
SELECT @@global.test_component.str_sys_var;

RESET PERSIST test_component.str_sys_var;

--echo # Should return "test":
SELECT @@global.test_component.str_sys_var;

--source include/restart_mysqld.inc

--echo # Should return NULL:
SELECT @@global.test_component.str_sys_var;

UNINSTALL COMPONENT "file://component_test_sys_var_service";

--echo # END OF TEST