Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit ab75eef

Browse files
committed
Add procedures to enable / disable consumers with a pattern.
1 parent c1167b5 commit ab75eef

File tree

6 files changed

+7171
-0
lines changed

6 files changed

+7171
-0
lines changed

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,42 @@ mysql> CALL sys.ps_setup_disable_instrument('');
14261426
1 row in set (0.01 sec)
14271427
```
14281428

1429+
#### ps_setup_disable_consumers
1430+
1431+
##### Description
1432+
1433+
Disables consumers within Performance Schema matching the input pattern.
1434+
1435+
Requires the SUPER privilege for "SET sql_log_bin = 0;".
1436+
1437+
##### Parameters
1438+
1439+
* consumer (VARCHAR(128)): A LIKE pattern match (using "%consumer%") of consumers to disable
1440+
1441+
##### Example
1442+
1443+
To disable all consumers:
1444+
```SQL
1445+
mysql> CALL sys.ps_setup_disable_comsumers(\'\');
1446+
+--------------------------+
1447+
| summary |
1448+
+--------------------------+
1449+
| Disabled 15 consumers |
1450+
+--------------------------+
1451+
1 row in set (0.02 sec)
1452+
```
1453+
1454+
To disable just the event_stage consumers:
1455+
```SQL
1456+
mysql> CALL sys.ps_setup_disable_comsumers(\'stage\');
1457+
+------------------------+
1458+
| summary |
1459+
+------------------------+
1460+
| Disabled 3 consumers |
1461+
+------------------------+
1462+
1 row in set (0.00 sec)
1463+
```
1464+
14291465
#### ps_setup_disable_thread
14301466

14311467
##### Description
@@ -1482,6 +1518,42 @@ mysql> CALL sys.ps_setup_enable_background_threads();
14821518
1 row in set (0.00 sec)
14831519
```
14841520

1521+
#### ps_setup_enable_consumers
1522+
1523+
##### Description
1524+
1525+
Enables consumers within Performance Schema matching the input pattern.
1526+
1527+
Requires the SUPER privilege for "SET sql_log_bin = 0;".
1528+
1529+
##### Parameters
1530+
1531+
* consumer (VARCHAR(128)): A LIKE pattern match (using "%consumer%") of consumers to enable
1532+
1533+
##### Example
1534+
1535+
To enable all consumers:
1536+
```SQL
1537+
mysql> CALL sys.ps_setup_enable_consumers(\'\');
1538+
+-------------------------+
1539+
| summary |
1540+
+-------------------------+
1541+
| Enabled 10 consumers |
1542+
+-------------------------+
1543+
1 row in set (0.02 sec)
1544+
```
1545+
1546+
To enable just "waits" consumers:
1547+
```SQL
1548+
mysql> CALL sys.ps_setup_enable_consumers(\'waits\');
1549+
+-----------------------+
1550+
| summary |
1551+
+-----------------------+
1552+
| Enabled 3 consumers |
1553+
+-----------------------+
1554+
1 row in set (0.00 sec)
1555+
```
1556+
14851557
#### ps_setup_enable_instrument
14861558

14871559
##### Description
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation; version 2 of the License.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15+
16+
DROP PROCEDURE IF EXISTS ps_setup_disable_comsumers;
17+
18+
DELIMITER $$
19+
20+
CREATE DEFINER='root'@'localhost' PROCEDURE ps_setup_disable_comsumers (
21+
IN consumer VARCHAR(128)
22+
)
23+
COMMENT '
24+
Description
25+
-----------
26+
27+
Disables consumers within Performance Schema
28+
matching the input pattern.
29+
30+
Requires the SUPER privilege for "SET sql_log_bin = 0;".
31+
32+
Parameters
33+
-----------
34+
35+
consumer (VARCHAR(128)):
36+
A LIKE pattern match (using "%consumer%") of consumers to disable
37+
38+
Example
39+
-----------
40+
41+
To disable all consumers:
42+
43+
mysql> CALL sys.ps_setup_disable_comsumers(\'\');
44+
+--------------------------+
45+
| summary |
46+
+--------------------------+
47+
| Disabled 15 consumers |
48+
+--------------------------+
49+
1 row in set (0.02 sec)
50+
51+
To disable just the event_stage consumers:
52+
53+
mysql> CALL sys.ps_setup_disable_comsumers(\'stage\');
54+
+------------------------+
55+
| summary |
56+
+------------------------+
57+
| Disabled 3 consumers |
58+
+------------------------+
59+
1 row in set (0.00 sec)
60+
'
61+
SQL SECURITY INVOKER
62+
NOT DETERMINISTIC
63+
MODIFIES SQL DATA
64+
BEGIN
65+
SET @log_bin := @@sql_log_bin;
66+
SET sql_log_bin = 0;
67+
68+
UPDATE performance_schema.setup_consumers
69+
SET enabled = 'NO'
70+
WHERE name LIKE CONCAT('%', consumer, '%');
71+
72+
SELECT CONCAT('Disabled ', @rows := ROW_COUNT(), ' consumer', IF(@rows != 1, 's', '')) AS summary;
73+
74+
SET sql_log_bin = @log_bin;
75+
END$$
76+
77+
DELIMITER ;
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation; version 2 of the License.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15+
16+
DROP PROCEDURE IF EXISTS ps_setup_enable_instrument;
17+
18+
DELIMITER $$
19+
20+
CREATE DEFINER='root'@'localhost' PROCEDURE ps_setup_enable_consumers (
21+
IN consumer VARCHAR(128)
22+
)
23+
COMMENT '
24+
Description
25+
-----------
26+
27+
Enables consumers within Performance Schema
28+
matching the input pattern.
29+
30+
Requires the SUPER privilege for "SET sql_log_bin = 0;".
31+
32+
Parameters
33+
-----------
34+
35+
consumer (VARCHAR(128)):
36+
A LIKE pattern match (using "%consumer%") of consumers to enable
37+
38+
Example
39+
-----------
40+
41+
To enable all consumers:
42+
43+
mysql> CALL sys.ps_setup_enable_consumers(\'\');
44+
+-------------------------+
45+
| summary |
46+
+-------------------------+
47+
| Enabled 10 consumers |
48+
+-------------------------+
49+
1 row in set (0.02 sec)
50+
51+
Query OK, 0 rows affected (0.02 sec)
52+
53+
To enable just "waits" consumers:
54+
55+
mysql> CALL sys.ps_setup_enable_consumers(\'waits\');
56+
+-----------------------+
57+
| summary |
58+
+-----------------------+
59+
| Enabled 3 consumers |
60+
+-----------------------+
61+
1 row in set (0.00 sec)
62+
63+
Query OK, 0 rows affected (0.00 sec)
64+
'
65+
SQL SECURITY INVOKER
66+
NOT DETERMINISTIC
67+
MODIFIES SQL DATA
68+
BEGIN
69+
SET @log_bin := @@sql_log_bin;
70+
SET sql_log_bin = 0;
71+
72+
UPDATE performance_schema.setup_consumers
73+
SET enabled = 'YES'
74+
WHERE name LIKE CONCAT('%', consumer, '%');
75+
76+
SELECT CONCAT('Enabled ', @rows := ROW_COUNT(), ' consumer', IF(@rows != 1, 's', '')) AS summary;
77+
78+
SET sql_log_bin = @log_bin;
79+
END$$
80+
81+
DELIMITER ;

sys_56.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ SOURCE ./procedures/ps_trace_statement_digest.sql
3131
SOURCE ./procedures/ps_trace_thread.sql
3232

3333
SOURCE ./procedures/ps_setup_disable_background_threads.sql
34+
SOURCE ./procedures/ps_setup_disable_consumers.sql
3435
SOURCE ./procedures/ps_setup_disable_instrument.sql
3536
SOURCE ./procedures/ps_setup_disable_thread.sql
3637

3738
SOURCE ./procedures/ps_setup_enable_background_threads.sql
39+
SOURCE ./procedures/ps_setup_enable_consumers.sql
3840
SOURCE ./procedures/ps_setup_enable_instrument.sql
3941
SOURCE ./procedures/ps_setup_enable_thread.sql
4042

0 commit comments

Comments
 (0)