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 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713
|
# Some functional checks for the content of the performance_schema table
# socket_summary_by_instance.
#
# Created: mleich 2011-07-01
#
# Rough description of "What is when tested"
# 1. Impact of successful connect
# A new row with EVENT_NAME "client_connection" shows up
# is tested in 0 and 4.5.
# 2. Impact of disconnect
# A row with EVENT_NAME "client_connection" disappears
# is tested in 0. and 2.
# 3. Disabling the instrumentation for some thread causes that the
# counter for this thread become static is tested in 4.3.
# Nearby the beginning of this test and somewhere in the middle.
# 4. TRUNCATE table resets the counters is tested in 5.
# 5. Consistency within a row like MIN_* <= AVG_* <= MAX_*
# -> include/socket_summary_check.inc which is called at
# various places
# 6. Consistency of the instances mentioned in socket_summary_by_event
# and socket_summary_by_instance is checked per call of
# include/socket_summary_check.inc
# 7. Check if changes in counters of instances caused by actions
# are reasonable is tested for
# - Connects+SQL statements in 4.1 and 4.2
# - SQL statements in 4.4
# - Connects in 4.5
#
# Embedded server does not supprt the performance_schema.
--source include/not_embedded.inc
--source include/not_windows.inc
--source include/no_valgrind_without_big.inc
--source include/have_perfschema.inc
# The values in the performance_schema tables depend on how much communication
# happens per SQL statement within our MTR tests. And there is a significant
# difference between standard statement execution and execution via
# prepared statement.
--source include/no_protocol.inc
#===================================
# Set IP address defaults with respect to IPV6 support
#
# Set this to enable debugging output
let $my_socket_debug_dbug= 0;
#
# Determine if IPV6 supported
#
let $check_ipv6_just_check= 1;
--source include/have_ipv4_mapped.inc
#
# Determine if IPV4 mapped to IPV6 supported
#
let $check_ipv4_mapped_just_check= 1;
--source include/have_ipv4_mapped.inc
#
# Set the localhost IP default to use when establishing connections
let $my_localhost=127.0.0.1;
if($check_ipv6_supported)
{
let $my_localhost=::1;
}
if($check_ipv4_mapped_supported)
{
let $my_localhost=::ffff:127.0.0.1;
}
#
let $my_socket_debug_dbug= 0;
if($my_socket_debug)
{
--echo IPV6=$check_ipv6_supported, IPV4_MAPPED = $check_ipv4_mapped_supported, LOCALHOST = $my_localhost
}
#===================================
--echo # The logging of commands and result sets is mostly disabled.
--echo # There are some messages which help to observe the progress of the test.
--echo # In case some check fails
--echo # - a message about this will be printed
--echo # - some SQL commands which show the unexpected state will be executed
--echo # (logging enabled)
--echo # - the test might abort
--echo #
--disable_query_log
--echo # 0. Check, build or set prequisites
#==========================================
# Set $print_details to 1 in case you want that the exact diffs caused
# by the execution of a statement get printed.
# Disadvantage of printing details:
# Even minor legimitate changes of the client - server communication can
# cause that the test needs maintenance.
# Advantage:
# More thorough checks.
# If any of the checks detects some suspicious/unexpected state than
# $print_details will be automatically switched to 1.
#
let $print_details= 0;
#
# Number of attempts within the test checking the stability of counter changes.
#
let $loop_rounds= 10;
# This test of PERFORMANCE_SCHEMA functionality is very vulnerable.
# Ensure that we have in the moment exact one
# - connection
# - instance with EVENT_NAME LIKE '%client_connection'
# - instance with EVENT_NAME LIKE '%server_tcpip_socket'
# - instance with EVENT_NAME LIKE '%server_unix_socket'
#=======================================================
let $my_rules= COUNT(*) = 1;
let $part=
FROM performance_schema.threads
WHERE NAME LIKE '%one_connection';
let $wait_condition=
SELECT $my_rules $part;
let $wait_timeout= 5;
--source include/wait_condition.inc
--enable_query_log
if(!$success)
{
--echo # ERROR: There must be only one user connection
eval
SELECT * $part;
--echo # abort
exit;
}
let $part=
FROM performance_schema.socket_summary_by_instance
WHERE EVENT_NAME LIKE '%client_connection';
let $wait_condition=
SELECT $my_rules $part;
let $wait_timeout= 5;
--source include/wait_condition.inc
if(!$success)
{
--echo # ERROR: There must be only one instance with this EVENT_NAME.
eval
SELECT * $part;
--echo # abort
exit;
}
let $part=
FROM performance_schema.socket_summary_by_instance
WHERE EVENT_NAME LIKE '%server_unix_socket';
let $wait_condition=
SELECT $my_rules $part;
let $wait_timeout= 5;
--source include/wait_condition.inc
if(!$success)
{
--echo # ERROR: There must be only one instance with this EVENT_NAME.
eval
SELECT * $part;
--echo # abort
exit;
}
let $part=
FROM performance_schema.socket_summary_by_instance
WHERE EVENT_NAME LIKE '%server_tcpip_socket';
let $wait_condition=
SELECT $my_rules $part;
let $wait_timeout= 5;
--source include/wait_condition.inc
if(!$success)
{
--echo # ERROR: There must be only one instance with this EVENT_NAME.
eval
SELECT * $part;
--echo # abort
exit;
}
--disable_query_log
#
# Lower the resolution of the wait timer from the default 'CYCLE'
# to 'NANOSECOND'.
# Hint: The timer columns contains values in picoseconds independent
# of the timer resolution.
# The timer resolution has an impact on the precision of the value.
# This should prevent the failures seen on some suspicious PB boxes where
# - calculations exceeded the BIGINT UNSIGNED (data type of the counter columns)
# value range.
# - we have reached from whatever reason 20 digit values
# The consequence for the current test is the following:
# The common sense rule
# In case COUNT_<A> increases than SUM_TIMER_<A> must also increase
# is no more valid because some action might need less time than the
# timer resolution.
#
let $wait_timer= `SELECT TIMER_NAME FROM performance_schema.setup_timers
WHERE NAME = 'wait'`;
UPDATE performance_schema.setup_timers
SET TIMER_NAME = 'NANOSECOND'
WHERE NAME = 'wait';
#
# Additional SCHEMA used for
# - detection of our "worker" session within the PROCESSLIST.
# No other connection should use this schema as default schema.
# - easy cleanup because auxiliary objects are stored there
#
CREATE SCHEMA mysqltest;
CREATE SCHEMA mysqlsupertest;
#
# Clear summary tables of previous entries
#
TRUNCATE performance_schema.socket_summary_by_instance;
TRUNCATE performance_schema.socket_summary_by_event_name;
# Disable instrumenting of the current default session.
# Required for check 1.1
UPDATE performance_schema.threads
SET INSTRUMENTED='NO' WHERE PROCESSLIST_ID = CONNECTION_ID();
#
# Auxiliary tables for storing current values at certain points of time.
# We store states of performance_schema.socket_summary_by_instance here
# in order
# - to have initial values from before some action
# - to minimize the impact of statements used for the checks on results.
# CREATE TEMPORARY TABLE my_socket_summary_by_instance AS
# would be nice but some statements are not supported for temporary tables.
#
# DECIMAL(60,0) is used instead of BIGINT UNSIGNED. The goal is to prevent
# errors during calculations
# Example:
# - A and B UNSIGNED BIGINT
# - A < B
# - A - B ---> Error
# though the columns in all queries are orderd to avoid this too.
#
CREATE TABLE mysqltest.my_socket_summary_by_instance (
EVENT_NAME varchar(128) NOT NULL,
OBJECT_INSTANCE_BEGIN bigint(20) unsigned NOT NULL,
COUNT_STAR DECIMAL(60,0) NOT NULL,
SUM_TIMER_WAIT DECIMAL(60,0) NOT NULL,
MIN_TIMER_WAIT DECIMAL(60,0) NOT NULL,
AVG_TIMER_WAIT DECIMAL(60,0) NOT NULL,
MAX_TIMER_WAIT DECIMAL(60,0) NOT NULL,
COUNT_READ DECIMAL(60,0) NOT NULL,
SUM_TIMER_READ DECIMAL(60,0) NOT NULL,
MIN_TIMER_READ DECIMAL(60,0) NOT NULL,
AVG_TIMER_READ DECIMAL(60,0) NOT NULL,
MAX_TIMER_READ DECIMAL(60,0) NOT NULL,
SUM_NUMBER_OF_BYTES_READ DECIMAL(60,0) NOT NULL,
COUNT_WRITE DECIMAL(60,0) NOT NULL,
SUM_TIMER_WRITE DECIMAL(60,0) NOT NULL,
MIN_TIMER_WRITE DECIMAL(60,0) NOT NULL,
AVG_TIMER_WRITE DECIMAL(60,0) NOT NULL,
MAX_TIMER_WRITE DECIMAL(60,0) NOT NULL,
SUM_NUMBER_OF_BYTES_WRITE DECIMAL(60,0) NOT NULL,
COUNT_MISC DECIMAL(60,0) NOT NULL,
SUM_TIMER_MISC DECIMAL(60,0) NOT NULL,
MIN_TIMER_MISC DECIMAL(60,0) NOT NULL,
AVG_TIMER_MISC DECIMAL(60,0) NOT NULL,
MAX_TIMER_MISC DECIMAL(60,0) NOT NULL,
pk VARCHAR(20),
PRIMARY KEY(pk, EVENT_NAME, OBJECT_INSTANCE_BEGIN)
) DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;
# The CAST(... AS DECIMAL(60,0)) prevents errors which might show up in case
# we run with the original data type UNSIGNED BIGINT.
CREATE TABLE mysqltest.socket_summary_by_instance_detail (
EVENT_NAME varchar(128) NOT NULL,
OBJECT_INSTANCE_BEGIN bigint(20) unsigned NOT NULL,
COUNT_READ DECIMAL(60,0) NOT NULL,
SUM_TIMER_READ DECIMAL(60,0) NOT NULL,
SUM_NUMBER_OF_BYTES_READ DECIMAL(60,0) NOT NULL,
COUNT_WRITE DECIMAL(60,0) NOT NULL,
SUM_TIMER_WRITE DECIMAL(60,0) NOT NULL,
SUM_NUMBER_OF_BYTES_WRITE DECIMAL(60,0) NOT NULL,
COUNT_MISC DECIMAL(60,0) NOT NULL,
SUM_TIMER_MISC DECIMAL(60,0) NOT NULL,
statement VARCHAR(500),
run INTEGER
) DEFAULT CHARSET=utf8;
#
# Auxiliary SQL functions used to shorten some commands.
#
CREATE FUNCTION mysqltest.min_of_triple
(f1 DECIMAL(60,0), f2 DECIMAL(60,0), f3 DECIMAL(60,0))
RETURNS DECIMAL(60,0)
RETURN IF(IF(f1 < f2,f1,f2) < f3,IF(f1 < f2,f1,f2), f3);
CREATE FUNCTION mysqltest.max_of_triple
(f1 DECIMAL(60,0), f2 DECIMAL(60,0), f3 DECIMAL(60,0))
RETURNS DECIMAL(60,0)
RETURN IF(IF(f1 > f2,f1,f2) > f3,IF(f1 > f2,f1,f2), f3);
#
# Auxiliary table for experiments with SELECTs earning different result sets.
#
CREATE TABLE mysqltest.my_aux (col1 INTEGER, col2 VARCHAR(1024), PRIMARY KEY(col1));
INSERT INTO mysqltest.my_aux SET col1 = 0, col2 = REPEAT('a',0);
INSERT INTO mysqltest.my_aux SET col1 = 1, col2 = REPEAT('a',0);
INSERT INTO mysqltest.my_aux SET col1 = 2, col2 = REPEAT('a',1);
INSERT INTO mysqltest.my_aux SET col1 = 3, col2 = REPEAT('a',1024);
#
# Auxiliary mysqltest variables used to shorten commands and to ensure
# that we run all time the right operation.
#
let $truncate=
TRUNCATE TABLE mysqltest.my_socket_summary_by_instance;
#
let $insert_before=
INSERT INTO mysqltest.my_socket_summary_by_instance
SELECT *,'Before' FROM performance_schema.socket_summary_by_instance;
#
let $insert_after=
INSERT INTO mysqltest.my_socket_summary_by_instance
SELECT *,'After' FROM performance_schema.socket_summary_by_instance;
#
let $insert_pseudo_before=
INSERT INTO mysqltest.my_socket_summary_by_instance
(EVENT_NAME, OBJECT_INSTANCE_BEGIN,
COUNT_STAR, SUM_TIMER_WAIT, MIN_TIMER_WAIT, AVG_TIMER_WAIT, MAX_TIMER_WAIT,
COUNT_READ, SUM_TIMER_READ, MIN_TIMER_READ, AVG_TIMER_READ, MAX_TIMER_READ,
SUM_NUMBER_OF_BYTES_READ,
COUNT_WRITE, SUM_TIMER_WRITE, MIN_TIMER_WRITE, AVG_TIMER_WRITE, MAX_TIMER_WRITE,
SUM_NUMBER_OF_BYTES_WRITE,
COUNT_MISC, SUM_TIMER_MISC, MIN_TIMER_MISC, AVG_TIMER_MISC, MAX_TIMER_MISC,
pk)
SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0,
0, 0, 0, 0, 0,
0,
0, 0, 0, 0, 0,
'Pseudo_Before'
FROM mysqltest.my_socket_summary_by_instance t1
WHERE OBJECT_INSTANCE_BEGIN NOT IN
(SELECT OBJECT_INSTANCE_BEGIN
FROM mysqltest.my_socket_summary_by_instance t2
WHERE pk = 'Before');
#
let $insert_delta=
INSERT INTO mysqltest.socket_summary_by_instance_detail
(EVENT_NAME,OBJECT_INSTANCE_BEGIN,
COUNT_READ, SUM_TIMER_READ, SUM_NUMBER_OF_BYTES_READ,
COUNT_WRITE,SUM_TIMER_WRITE,SUM_NUMBER_OF_BYTES_WRITE,
COUNT_MISC, SUM_TIMER_MISC, statement,run)
SELECT EVENT_NAME,OBJECT_INSTANCE_BEGIN,
t1.COUNT_READ - t2.COUNT_READ,
t1.SUM_TIMER_READ - t2.SUM_TIMER_READ,
t1.SUM_NUMBER_OF_BYTES_READ - t2.SUM_NUMBER_OF_BYTES_READ,
t1.COUNT_WRITE - t2.COUNT_WRITE,
t1.SUM_TIMER_WRITE - t2.SUM_TIMER_WRITE,
t1.SUM_NUMBER_OF_BYTES_WRITE - t2.SUM_NUMBER_OF_BYTES_WRITE,
t1.COUNT_MISC - t2.COUNT_MISC,
t1.SUM_TIMER_MISC - t2.SUM_TIMER_MISC,
NULL,NULL
FROM mysqltest.my_socket_summary_by_instance t1
JOIN mysqltest.my_socket_summary_by_instance t2
USING (EVENT_NAME,OBJECT_INSTANCE_BEGIN)
WHERE t1.pk = 'After' AND t2.pk LIKE '%Before';
#
let $get_object_instance_begin=
SELECT OBJECT_INSTANCE_BEGIN INTO @con1_object_instance_begin
FROM performance_schema.socket_summary_by_instance AS t1
WHERE (EVENT_NAME,OBJECT_INSTANCE_BEGIN)
NOT IN (SELECT EVENT_NAME,OBJECT_INSTANCE_BEGIN
FROM mysqltest.my_socket_summary_by_instance AS t2
WHERE pk = 'Before');
# Use this whenever you print data.
let $column_list=
RPAD(EVENT_NAME, 38, ' ') AS EVENT_NAME,
LPAD(OBJECT_INSTANCE_BEGIN, 20, ' ') AS OBJECT_INSTANCE,
LPAD(COUNT_READ, 7, ' ') AS CREAD,
LPAD(SUM_TIMER_READ, 12, ' ') AS TREAD,
LPAD(SUM_NUMBER_OF_BYTES_READ, 7, ' ') AS BREAD,
LPAD(COUNT_WRITE, 7, ' ') AS CWRITE,
LPAD(SUM_TIMER_WRITE, 12, ' ') AS TWRITE,
LPAD(SUM_NUMBER_OF_BYTES_WRITE, 7, ' ') AS BWRITE,
LPAD(COUNT_MISC, 7, ' ') AS CMISC,
LPAD(SUM_TIMER_MISC, 13, ' ') AS TMISC,
RPAD(STATEMENT, 50, ' ') AS STATEMENT,
LPAD(RUN, 5, ' ') AS RUN;
# Determine OBJECT_INSTANCE_BEGIN of the connection default
# which acts as the observer
eval $truncate;
eval $insert_before;
--disconnect default
--connect (default,localhost,root,,,,)
# --echo ########### Disconnect/Connect
# --enable_query_log
eval $insert_after;
eval $get_object_instance_begin;
SET @default_object_instance_begin = @con1_object_instance_begin;
# Wait till the old default connection has disappeared
let $wait_timeout= 5;
let $wait_condition=
SELECT COUNT(*) = 1
FROM performance_schema.threads
WHERE processlist_user = 'root';
--source include/wait_condition.inc
--enable_query_log
if (!$success)
{
--enable_query_log
--enable_result_log
--echo # Error: The disconnect of the old default connection
--echo # (user = 'root') failed. We expect to have only one connection
--echo # with user = 'root'. And this is our current connection.
SELECT * FROM performance_schema.threads
WHERE processlist_user = 'root';
--echo # abort
exit;
}
# Disable instrumenting of the current default session.
# Required for check 1.2
UPDATE performance_schema.threads
SET INSTRUMENTED='NO' WHERE PROCESSLIST_ID = CONNECTION_ID();
--echo # 1. Basic checks
--echo # 1.1 Check that the entry of the disconnected old default session really
--echo # disappeared from performance_schema.socket_summary_by_instance.
#===============================================================================
# This failed at some point in history when the instrumenting for the
# session to be disconnected was disabled.
if(`SELECT COUNT(*) FROM performance_schema.socket_summary_by_instance
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND EVENT_NAME LIKE '%client_connection'`)
{
--enable_query_log
--enable_result_log
--echo # Error: The disconnected old default session did not disappear from
--echo # socket_summary_by_instance.
SELECT * FROM performance_schema.socket_summary_by_instance
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND EVENT_NAME LIKE '%client_connection';
}
TRUNCATE TABLE performance_schema.socket_summary_by_instance;
--echo # 1.2 Check the base line
#===============================
eval $truncate;
--source ../include/socket_summary_check.inc
# --disable_query_log
# --disable_query_log
--echo # 2. Variations on Connect
let $is_connect= 1;
--echo # 2.1 Connect fails because the user is unknown
--echo # length of user name = 4 character
--echo # length of default db = 9 character
#========================================================================
let $connect_host= localhost;
let $connect_db= mysqltest;
let $connect_user= boot;
--source ../include/socket_event.inc
--echo # 2.2 Connect fails because the user is unknown
--echo # length of user name = 14 character (10 more than in 2.1)
--echo # length of default db = 9 character
#========================================================================
let $connect_host= localhost;
let $connect_db= mysqltest;
let $connect_user= boot0123456789;
--source ../include/socket_event.inc
--echo # 2.3 Connect should pass, host = localhost
--echo # length of user name = 4 character
--echo # length of default db = 9 character
#========================================================================
let $connect_host= localhost;
let $connect_db= mysqltest;
let $connect_user= root;
--source ../include/socket_event.inc
--echo # 2.4 Connect should pass, host = localhost
--echo # length of user name = 4 character
--echo # length of default db = 14 character (5 more than 2.3)
#========================================================================
let $connect_host= localhost;
let $connect_db= mysqlsupertest;
let $connect_user= root;
--source ../include/socket_event.inc
--echo # 2.5 Connect should pass, host = localhost
--echo # length of user name = 10 character
--echo # length of default db = 9 character
#========================================================================
CREATE USER 'root012345'@'localhost';
GRANT ALL PRIVILEGES ON *.* TO 'root012345'@'localhost';
let $connect_host= localhost;
let $connect_db= mysqltest;
let $connect_user= root012345;
--source ../include/socket_event.inc
DROP USER 'root012345'@'localhost';
--echo # 2.6 Connect should pass, host = localhost
--echo # length of user name = 14 character
--echo # length of default db = 9 character
#========================================================================
CREATE USER 'root0123456789'@'localhost';
GRANT ALL PRIVILEGES ON *.* to 'root0123456789'@'localhost';
let $connect_host= localhost;
let $connect_db= mysqltest;
let $connect_user= root0123456789;
--source ../include/socket_event.inc
DROP USER 'root0123456789'@'localhost';
--echo # 2.7 Connect should pass, host = my_localhost
--echo # length of user name = 4 character
--echo # length of default db = 9 character
--echo # connection runs through server_tcpip_socket !
#========================================================================
let $connect_host= $my_localhost;
let $connect_db= mysqltest;
let $connect_user= root;
--source ../include/socket_event.inc
#========================================================================
--connect (con1,localhost,root,,mysqltest,,)
# Experiments showed some unexpected result in the counter difference
# which got con1 for the next statement (see 3.1).
# The measured diff was too high and was probably caused by some
# too much delayed counter maintenance for the connect.
# We run here just some SQL statement because counter maintenance
# for SQL statements is more fast and reliable than far Connect.
DO 1;
--connection default
--source ../include/wait_till_sleep.inc
--disable_query_log
--echo # 3 Variations on SELECT
# Attention: Don't use
# - any double quotes within the statements because sourced scripts
# already "decorate" $variables with double quotes
# - UNION because this leads to result set related byte write
# counters which cannot good compared to select without union
let $is_connect= 0;
eval $get_object_instance_begin;
--echo # 3.1 Check a SELECT ending with server sending an error message.
--echo # Error message is short (unknown table).
#========================================================================
let $statement= SELECT col2 FROM does_not_exist;
--source ../include/socket_event.inc
--echo # 3.2 SELECT ending with server sending an error message.
--echo # Now the statement is a bit longer but the error message
--echo # length does again not depend on statement.
#=======================================================================
let $statement= SELECT col2 FROM does_not_exist WHERE col1 = 0;
--source ../include/socket_event.inc
--echo # 3.3 SELECT ending with server sending an error message.
--echo # The statement has the same length like in 3.2 but the error
--echo # message is now different and much longer.
#=======================================================================
let $statement= SELECT col2 FROM does_not_exist WHERE col1 A 0;
--source ../include/socket_event.inc
--echo # 3.4 SELECT ending with server sending an error message.
--echo # Statement and error message are a bit longer than in 3.1
--echo # because the table name is longer.
#=======================================================================
let $statement= SELECT col2 FROM does_not_exist0123;
--source ../include/socket_event.inc
--echo # 3.5 SELECT earning an empty result set.
#=======================================================
let $statement= SELECT col2 FROM mysqltest.my_aux WHERE col1 = -1;
--source ../include/socket_event.inc
--echo # 3.6 SELECT earning an empty result set.
--echo # Short column name is replaced by longer alias.
#==========================================================
let $statement= SELECT col2 AS my_super_col FROM mysqltest.my_aux WHERE col1 = -1;
--source ../include/socket_event.inc
--echo # 3.7 SELECT earning one row with an empty string.
#================================================================
let $statement= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1;
--source ../include/socket_event.inc
--echo # 3.8 SELECT earning one row with one string one char long.
#=========================================================================
let $statement= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 2;
--source ../include/socket_event.inc
--echo # 3.9 SELECT earning one row with one string 1024 char long.
#==========================================================================
let $statement= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 3;
--source ../include/socket_event.inc
--echo # 3.10 SELECT earning two rows with an empty string
#==========================================================================
let $statement= SELECT col2 FROM mysqltest.my_aux WHERE col1 < 2;
--source ../include/socket_event.inc
--echo # 3.11 Check that the preceding Connects/SQL command runs have not
--echo # caused some unexpected state.
#==========================================================================
let $my_rules= COUNT(*) = 2;
let $part=
FROM performance_schema.threads
WHERE NAME LIKE '%one_connection';
if(`SELECT NOT ( $my_rules ) $part `)
{
--echo # ERROR: There must be only two user connections
eval
SELECT * $part;
--echo # abort
exit;
}
let $part=
FROM performance_schema.socket_summary_by_instance
WHERE EVENT_NAME LIKE '%client_connection';
if(`SELECT NOT ( $my_rules ) $part `)
{
--echo # ERROR: There must be only two instances with this EVENT_NAME.
eval
SELECT * $part;
--echo # abort
exit;
}
let $my_rules= COUNT(*) = 1;
let $part=
FROM performance_schema.socket_summary_by_instance
WHERE EVENT_NAME LIKE '%server_unix_socket';
if(`SELECT NOT ( $my_rules ) $part `)
{
--echo # ERROR: There must be only one instance with this EVENT_NAME.
eval
SELECT * $part;
--echo # abort
exit;
}
let $part=
FROM performance_schema.socket_summary_by_instance
WHERE EVENT_NAME LIKE '%server_tcpip_socket';
if(`SELECT NOT ( $my_rules ) $part `)
{
--echo # ERROR: There must be only one instance with this EVENT_NAME.
eval
SELECT * $part;
--echo # abort
exit;
}
--echo # 4. Check delta (value_after_action - value_before_action) details
# 4.0 . Negative deltas cannot have happened because the counter columns within
# socket_summary_by_instance_detail are defined as UNSIGNED BIGINT.
# = The INSERT which computes the diff would have been failed.
--echo # 4.1 Check that
--echo # - no change in COUNT_* leads to no change in
--echo # SUM_TIMER_* and no change in SUM_NUMBER_OF_BYTES_*
--echo # - increased COUNT_READ leads to increased
--echo # SUM_NUMBER_OF_BYTES_READ
--echo # - increased COUNT_WRITE leads to increased
--echo # SUM_NUMBER_OF_BYTES_WRITE
--echo # Attention:
--echo # The time required for some action might be below timer resolution.
--echo # Therefore some increased COUNT_* does not need to lead to an
--echo # increased SUM_TIMER_*.
#==========================================================================
# Enable the following lines for debugging the check.
# Attention: socket_summary_by_instance_detail is after that rotten.
if(0)
{
--enable_info
UPDATE mysqltest.socket_summary_by_instance_detail
SET SUM_TIMER_MISC = 13, COUNT_MISC = 0
WHERE statement LIKE '%WHERE col1 = 3'
AND EVENT_NAME LIKE '%client_connection'
AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
LIMIT 1;
--disable_info
}
let $my_rules=
((COUNT_READ = 0 AND SUM_TIMER_READ = 0 AND SUM_NUMBER_OF_BYTES_READ = 0)
OR
(COUNT_READ > 0 AND SUM_NUMBER_OF_BYTES_READ > 0))
AND
((COUNT_WRITE = 0 AND SUM_TIMER_WRITE = 0 AND SUM_NUMBER_OF_BYTES_WRITE = 0)
OR
(COUNT_WRITE > 0 AND SUM_NUMBER_OF_BYTES_WRITE > 0))
AND
((COUNT_MISC = 0 AND SUM_TIMER_MISC = 0)
OR
(COUNT_MISC > 0));
if(`SELECT COUNT(*) FROM mysqltest.socket_summary_by_instance_detail
WHERE NOT ( $my_rules ) `)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo #
eval
SELECT
$column_list
FROM mysqltest.socket_summary_by_instance_detail
WHERE NOT ( $my_rules )
ORDER BY EVENT_NAME, OBJECT_INSTANCE, STATEMENT, RUN;
let $print_details= 1;
}
--echo # 4.2 Results must be stable
#==========================================================================
# Enable the following lines for debugging the check.
# Attention: socket_summary_by_instance_detail is after that rotten.
if(0)
{
--enable_info
UPDATE mysqltest.socket_summary_by_instance_detail
SET COUNT_WRITE = 13
WHERE statement LIKE '%WHERE col1 = 3'
AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND EVENT_NAME LIKE '%client_connection'
LIMIT 1;
--disable_info
}
# eval
# SELECT
# $column_list
# FROM mysqltest.socket_summary_by_instance_detail
# WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
# ORDER BY EVENT_NAME, statement,run;
# In case we are able to wait all time till perfschema has finished the
# maintenance of counters than the following must be valid.
let $my_rules=
COUNT(DISTINCT SUM_NUMBER_OF_BYTES_READ) = 1 AND
COUNT(DISTINCT COUNT_WRITE) = 1 AND
COUNT(DISTINCT SUM_NUMBER_OF_BYTES_WRITE) = 1;
# In case we do not get the results somehow deterministic than we
# we should go with the less strict check based on CV.
#
# Compute coefficient of variation (CV) to detect 'notable' variances in the
# byte count and operation counts. The acceptable range for the CV is purely
# subjective, however, the CV is a dimensionless quantity therefore valid
# across platforms.
# let $my_rules=
# STD(COUNT_READ)/AVG(COUNT_READ) <= 0.2 AND
# STD(SUM_NUMBER_OF_BYTES_READ)/AVG(SUM_NUMBER_OF_BYTES_READ) <= 0.2 AND
# STD(COUNT_WRITE)/AVG(COUNT_WRITE) <= 0.2 AND
# STD(SUM_NUMBER_OF_BYTES_WRITE)/AVG(SUM_NUMBER_OF_BYTES_WRITE) <= 0.2 AND
# STD(COUNT_MISC)/AVG(COUNT_MISC) <= 0.4;
let $part=
FROM mysqltest.socket_summary_by_instance_detail
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
GROUP BY EVENT_NAME, statement
HAVING NOT ($my_rules) ;
if(`SELECT COUNT(statement) $part`)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo # for GROUP BY EVENT_NAME, statement
eval
SELECT $column_list
FROM mysqltest.socket_summary_by_instance_detail
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND (EVENT_NAME, statement)
IN (SELECT EVENT_NAME, statement
$part)
ORDER BY EVENT_NAME, statement, run, OBJECT_INSTANCE_BEGIN;
let $print_details= 1;
}
--echo # 4.3 Counters must be 0 in client_connection for the default session
--echo # Instrumenting is disabled since a long time and the counter were
--echo # reset via TRUNCATE just after the disabling.
#==========================================================================
let $my_rules=
COUNT_STAR = 0 AND SUM_TIMER_WAIT = 0
AND
COUNT_READ = 0 AND SUM_TIMER_READ = 0 AND SUM_NUMBER_OF_BYTES_READ = 0
AND
COUNT_WRITE = 0 AND SUM_TIMER_WRITE = 0 AND SUM_NUMBER_OF_BYTES_WRITE = 0
AND
COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
if(`SELECT COUNT(*) FROM performance_schema.socket_summary_by_instance
WHERE NOT ( $my_rules )
AND OBJECT_INSTANCE_BEGIN = @default_object_instance_begin`)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo #
# Attention: We use here performance_schema.socket_summary_by_instance
# and not mysqltest.socket_summary_by_instance_detail.
# Therefore the convenient $column_list cannot be used.
eval
SELECT
COUNT_STAR, SUM_TIMER_WAIT,
COUNT_READ,SUM_TIMER_READ,SUM_NUMBER_OF_BYTES_READ,
COUNT_WRITE,SUM_TIMER_WRITE,SUM_NUMBER_OF_BYTES_WRITE,
COUNT_MISC,SUM_TIMER_MISC
FROM performance_schema.socket_summary_by_instance
WHERE OBJECT_INSTANCE_BEGIN = @default_object_instance_begin;
let $print_details= 1;
}
#---------------------------------------------------------------------------
--echo # 4.4 Check the differences caused by SQL statements
--echo # 4.4.1 There must be no changes in counters of instances
--echo # NOT LIKE '%client_connection' because everything gets charged
--echo # into client_connection of the acting connection.
#===========================================================================
# Enable the following lines for debugging the check.
# Attention: socket_summary_by_instance_detail is after that rotten.
if(0)
{
--enable_info
UPDATE mysqltest.socket_summary_by_instance_detail
SET COUNT_WRITE = 13
WHERE statement LIKE '%WHERE col1 = 3'
AND EVENT_NAME NOT LIKE '%client_connection'
LIMIT 1;
--disable_info
}
let $my_rules=
COUNT_READ = 0 AND SUM_TIMER_READ = 0 AND SUM_NUMBER_OF_BYTES_READ = 0
AND
COUNT_WRITE = 0 AND SUM_TIMER_WRITE = 0 AND SUM_NUMBER_OF_BYTES_WRITE = 0
AND
COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
let $part=
FROM mysqltest.socket_summary_by_instance_detail
WHERE NOT ( $my_rules )
AND EVENT_NAME NOT LIKE '%client_connection'
AND statement NOT LIKE 'Connect%';
if(`SELECT COUNT(*) $part`)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo #
eval
SELECT
$column_list
$part
ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN, statement, run;
let $print_details= 1;
}
--echo # 4.4.2 In case of SELECT and our scenarios even COUNT_READ and COUNT_MISC
--echo # are stable.
#===========================================================================
# Enable the following lines for debugging the check.
# Attention: socket_summary_by_instance_detail is after that rotten.
if(0)
{
--enable_info
UPDATE mysqltest.socket_summary_by_instance_detail
SET COUNT_READ = 13
WHERE statement LIKE '%WHERE col1 = 3'
LIMIT 1;
--disable_info
}
let $my_rules=
COUNT(DISTINCT COUNT_READ) = 1 AND
COUNT(DISTINCT COUNT_MISC) = 1;
let $part=
FROM mysqltest.socket_summary_by_instance_detail
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND statement NOT LIKE '%Connect%'
GROUP BY EVENT_NAME, statement
HAVING NOT ($my_rules) ;
if(`SELECT COUNT(statement) $part`)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo # for GROUP BY EVENT_NAME, statement
eval
SELECT $column_list
FROM mysqltest.socket_summary_by_instance_detail
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND (EVENT_NAME, statement)
IN (SELECT EVENT_NAME, statement
$part)
ORDER BY EVENT_NAME, statement, run, OBJECT_INSTANCE_BEGIN;
let $print_details= 1;
}
--echo # 4.4.3 In our testing scenarios we get for the client_connection entry
--echo # of the acting connection
--echo # -> OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
--echo # COUNT_MISC = 0 AND SUM_TIMER_MISC = 0
#===========================================================================
# Enable the following lines for debugging the check.
# Attention: socket_summary_by_instance_detail is after that rotten.
if(0)
{
--enable_info
UPDATE mysqltest.socket_summary_by_instance_detail
SET COUNT_MISC = 13
WHERE statement LIKE '%WHERE col1 = 3'
AND EVENT_NAME LIKE '%client_connection'
AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
LIMIT 1;
--disable_info
}
let $my_rules=
COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
let $part=
FROM mysqltest.socket_summary_by_instance_detail
WHERE NOT ( $my_rules )
AND EVENT_NAME LIKE '%client_connection'
AND statement NOT LIKE 'Connect%'
AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin;
if(`SELECT COUNT(*) $part`)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo #
eval
SELECT
$column_list
$part
ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN, statement, run;
let $print_details= 1;
}
# Initialize variables
let $my_rules= my_rules_not_set;
let $stmt1= stmt1_not_set;
let $stmt2= stmt2_not_set;
# $title_prefix is used for the generation of titles
let $title_prefix= 4.4;
# $check_num is used for the generation of titles and gets incremented after
# every call of the current script.
let $check_num= 4;
# $column_list is used for the generation of error information and valid for
# every sub test.
let $diff_column_list=
t2.COUNT_READ - t1.COUNT_READ AS D_COUNT_READ,
t2.COUNT_READ AS S2_COUNT_READ,
t1.COUNT_READ AS S1_COUNT_READ,
t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ AS D_SUM_NUMBER_OF_BYTES_READ,
t2.SUM_NUMBER_OF_BYTES_READ AS S2_SUM_NUMBER_OF_BYTES_READ,
t1.SUM_NUMBER_OF_BYTES_READ AS S1_SUM_NUMBER_OF_BYTES_READ,
t2.COUNT_WRITE - t1.COUNT_WRITE AS D_COUNT_WRITE,
t2.COUNT_WRITE AS S2_COUNT_WRITE,
t1.COUNT_WRITE AS S1_COUNT_WRITE,
t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE AS D_SUM_NUMBER_OF_BYTES_WRITE,
t2.SUM_NUMBER_OF_BYTES_WRITE AS S2_SUM_NUMBER_OF_BYTES_WRITE,
t1.SUM_NUMBER_OF_BYTES_WRITE AS S1_SUM_NUMBER_OF_BYTES_WRITE,
t2.COUNT_MISC - t1.COUNT_MISC AS D_COUNT_MISC,
t2.COUNT_MISC AS S2_COUNT_MISC,
t1.COUNT_MISC AS S1_COUNT_MISC;
# $part is used for the generation of "check" statements + error information
# and valid for every sub test.
let $part=
FROM mysqltest.socket_summary_by_instance_detail t1
JOIN mysqltest.socket_summary_by_instance_detail t2
USING (EVENT_NAME, OBJECT_INSTANCE_BEGIN, run)
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND EVENT_NAME LIKE ('%client_connection')
AND run = 1;
--echo # Check the differences between changes caused by SQL statements
--echo # These differences must correspond to parameters like
--echo # - statement, table name or column name length
--echo # - number of rows in result set, size of rows in result set etc.
# --> Statement NOT LIKE '%Connect%'
let stmt1= SELECT col2 FROM does_not_exist;
let stmt2= SELECT col2 FROM does_not_exist WHERE col1 = 0;
#
# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
# 3 36 1 59 1 SELECT col2 FROM does_not_exist
# 3 51 1 59 1 SELECT col2 FROM does_not_exist WHERE col1 = 0
# The string of the statement gets charged into SUM_NUMBER_OF_BYTES_READ.
# The server error message gets charged into SUM_NUMBER_OF_BYTES_WRITE.
let $msg=
# One statement is longer than the other.
# Both statements fail with the same error message (table does not exist);
#
let $my_rules=
t2.COUNT_READ - t1.COUNT_READ = 0 AND
t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE = 0 AND
t2.COUNT_MISC - t1.COUNT_MISC = 0;
--source ../include/socket_check1.inc
let $stmt1= SELECT col2 FROM does_not_exist WHERE col1 = 0;
let $stmt2= SELECT col2 FROM does_not_exist WHERE col1 A 0;
#
# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
# 3 51 1 59 1 SELECT col2 FROM does_not_exist WHERE col1 = 0
# 3 51 1 162 1 SELECT col2 FROM does_not_exist WHERE col1 A 0
let $msg=
# Both statements have the same length and fail.
# The length of the error messages differs.;
let $my_rules=
t2.COUNT_READ - t1.COUNT_READ = 0 AND
t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE > 0 AND
t2.COUNT_MISC - t1.COUNT_MISC = 0;
--source ../include/socket_check1.inc
let $stmt1= SELECT col2 FROM does_not_exist;
let $stmt2= SELECT col2 FROM does_not_exist0123;
# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
# 3 36 1 59 1 SELECT col2 FROM does_not_exist
# 3 40 1 63 1 SELECT col2 FROM does_not_exist0123
let $msg=
# Both statements fail (table does not exist).
# The length of the statement and the length of the error messages differs.
# Reason for both differences is the length of the table name.;
let $my_rules=
t2.COUNT_READ - t1.COUNT_READ = 0 AND
t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE = LENGTH('$stmt2') - LENGTH('$stmt1') AND
t2.COUNT_MISC - t1.COUNT_MISC = 0;
--source ../include/socket_check1.inc
# Assuming that some new check should be added.
# How to enforce that a lot info is printed so that it becomes easy to derive
# the right value for $my_rules?
#----------------------------------------------------------------------------
# let $my_rules= 0;
# This will cause that suite/perfschema/include/socket_check1.inc concludes that
# the check via $my_rules failed and it will print debug information.
# let $stmt1= SELECT col2 FROM does_not_exist WHERE col1 = 0;
# let $stmt2= SELECT col2 FROM does_not_exist WHERE col1 A 0;
# let $my_rules= 0;
# --source ../include/socket_check1.inc
let $stmt2= SELECT col2 AS my_super_col FROM mysqltest.my_aux WHERE col1 = -1;
let $stmt1= SELECT col2 FROM mysqltest.my_aux WHERE col1 = -1;
#
# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
# 3 54 1 78 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = -1
# 3 70 1 86 1 SELECT col2 AS my_super_col FROM mysqltest.my_aux WHERE col1 = -1
let $msg=
# Both statements get an empty result set.
# The length of the statements and the length of the result sets differs.
# Reason for both differences is the length of the some column name.;
let $my_rules=
t2.COUNT_READ - t1.COUNT_READ = 0 AND
t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE = LENGTH('my_super_col') - LENGTH('col2') AND
t2.COUNT_MISC - t1.COUNT_MISC = 0;
--source ../include/socket_check1.inc
let $stmt2= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1;
let $stmt1= SELECT col2 FROM mysqltest.my_aux WHERE col1 = -1;
#
# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
# t1 3 54 1 78 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = -1
# t2 3 53 1 83 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1
let $msg=
# Both statements differ in the statement length.
# One statement earns an empty result set.
# The other statement earns one row containing an empty string.;
let $my_rules=
t2.COUNT_READ - t1.COUNT_READ = 0 AND
t1.SUM_NUMBER_OF_BYTES_READ - t2.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt1') - LENGTH('$stmt2') AND
t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE > 0 AND
t2.COUNT_MISC - t1.COUNT_MISC = 0;
--source ../include/socket_check1.inc
let $stmt2= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 2;
let $stmt1= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1;
#
# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
# 3 53 1 83 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1
# 3 53 1 84 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 2
let $msg=
# Both statements have the same length.
# One statement earns an one row containing an empty string.
# The other statement earns one row containing a string 1 byte long.;
let $my_rules=
t2.COUNT_READ - t1.COUNT_READ = 0 AND
t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE = 1 AND
t2.COUNT_MISC - t1.COUNT_MISC = 0;
--source ../include/socket_check1.inc
let $stmt2= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 3;
let $stmt1= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1;
#
# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
# 3 53 1 83 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1
# 3 53 1 1109 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 3
let $msg=
# Both statements have the same length.
# One statement earns an one row containing an empty string.
# The other statement earns one row containing a string 1024 byte long.;
let $my_rules=
t2.COUNT_READ - t1.COUNT_READ = 0 AND
t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE >= 1024 AND
t2.COUNT_MISC - t1.COUNT_MISC = 0;
--source ../include/socket_check1.inc
let $stmt2= SELECT col2 FROM mysqltest.my_aux WHERE col1 < 2;
let $stmt1= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1;
#
# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
# t1 3 53 1 83 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1
# t2 3 53 1 88 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 < 2
let $msg=
# Both statements have the same length.
# One statement earns an one row containing an empty string.
# The other statement earns two rows containing an empty string.;
let $my_rules=
t2.COUNT_READ - t1.COUNT_READ = 0 AND
t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE > 0 AND
t2.COUNT_MISC - t1.COUNT_MISC = 0;
--source ../include/socket_check1.inc
--echo # 4.5 Check the differences caused by Connects
--echo # Attention: Succesful Connects run an additional "DO 1".
--echo # 4.5.1 Connects do not charge anything into READ or WRITE counters
--echo # of the instance with EVENT_NAME NOT LIKE ('%client_connection%').
--echo # This mean all these counters must be 0.
let $my_rules=
COUNT_READ = 0 AND SUM_TIMER_READ = 0 AND SUM_NUMBER_OF_BYTES_READ = 0 AND
COUNT_WRITE = 0 AND SUM_TIMER_WRITE = 0 AND SUM_NUMBER_OF_BYTES_WRITE = 0;
let $part=
FROM mysqltest.socket_summary_by_instance_detail
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND statement LIKE ('%Connect%')
AND EVENT_NAME NOT LIKE ('%client_connection%')
AND NOT ( $my_rules );
if(`SELECT COUNT(*) $part `)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo #
eval
SELECT
$column_list
$part;
let $print_details= 1;
}
--echo # 4.5.2 Connects using for host the value 'localhost'
--echo # 4.5.2.1 For the instance with EVENT_NAME LIKE '%server_tcpip_socket'
--echo # COUNT_MISC = 0 AND SUM_TIMER_MISC = 0 must be valid
--echo # because we run through server_unix_socket.
#===========================================================================
# Enable the following lines for debugging the check.
# Attention: socket_summary_by_instance_detail is after that rotten.
if(0)
{
--enable_info
UPDATE mysqltest.socket_summary_by_instance_detail
SET COUNT_MISC = 13
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND statement LIKE ('%Connect%localhost%')
AND EVENT_NAME LIKE ('%server_tcpip_socket%')
LIMIT 1;
--disable_info
}
let $my_rules=
COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
let $part=
FROM mysqltest.socket_summary_by_instance_detail
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND statement LIKE ('%Connect%localhost%')
AND EVENT_NAME LIKE ('%server_tcpip_socket%')
AND NOT ( $my_rules );
if(`SELECT COUNT(*) $part `)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo #
eval
SELECT
$column_list
$part;
let $print_details= 1;
}
--echo # 4.5.2.2 For the instance with EVENT_NAME LIKE '%server_unix_socket'
--echo # COUNT_MISC > 0 must be valid.
#===========================================================================
# Enable the following lines for debugging the check.
# Attention: socket_summary_by_instance_detail is after that rotten.
if(0)
{
--enable_info
UPDATE mysqltest.socket_summary_by_instance_detail
SET COUNT_MISC = 0
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND statement LIKE ('%Connect%localhost%')
AND EVENT_NAME LIKE ('%server_unix_socket%')
LIMIT 1;
--disable_info
}
let $my_rules=
COUNT_MISC > 0;
let $part=
FROM mysqltest.socket_summary_by_instance_detail
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND statement LIKE ('%Connect%localhost%')
AND EVENT_NAME LIKE ('%server_unix_socket%')
AND NOT ( $my_rules );
if(`SELECT COUNT(*) $part `)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo #
eval
SELECT
$column_list
$part;
let $print_details= 1;
}
--echo # 4.5.3 Connects using for host a value <> 'localhost'
--echo # 4.5.3.1 For the instance with EVENT_NAME LIKE '%server_unix_socket'
--echo # COUNT_MISC = 0 AND SUM_TIMER_MISC = 0 must be valid
--echo # because we run through server_tcpip_socket.
#===========================================================================
# Enable the following lines for debugging the check.
# Attention: socket_summary_by_instance_detail is after that rotten.
if(0)
{
--enable_info
eval
UPDATE mysqltest.socket_summary_by_instance_detail
SET COUNT_MISC = 13
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND EVENT_NAME LIKE ('%server_unix_socket%')
AND statement LIKE ('%Connect%$my_localhost%')
LIMIT 1;
--disable_info
}
let $my_rules=
COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
let $part=
FROM mysqltest.socket_summary_by_instance_detail
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND statement LIKE ('%Connect%$my_localhost%')
AND EVENT_NAME LIKE ('%server_unix_socket%')
AND NOT ( $my_rules );
if(`SELECT COUNT(*) $part `)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo #
eval
SELECT
$column_list
$part;
let $print_details= 1;
}
--echo # 4.5.3.2 For the instance with EVENT_NAME LIKE '%server_tcpip_socket'
--echo # COUNT_MISC > 0 must be valid.
#===========================================================================
# Enable the following lines for debugging the check.
# Attention: socket_summary_by_instance_detail is after that rotten.
if(0)
{
--enable_info
eval
UPDATE mysqltest.socket_summary_by_instance_detail
SET COUNT_MISC = 0
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND statement LIKE ('%Connect%$my_localhost%')
AND EVENT_NAME LIKE ('%server_tcpip_socket%')
LIMIT 1;
--disable_info
}
let $my_rules=
COUNT_MISC > 0;
let $part=
FROM mysqltest.socket_summary_by_instance_detail
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND statement LIKE ('%Connect%$my_localhost%')
AND EVENT_NAME LIKE ('%server_tcpip_socket%')
AND NOT ( $my_rules );
if(`SELECT COUNT(*) $part `)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo #
eval
SELECT
$column_list
$part;
let $print_details= 1;
}
--echo # 4.5.4 Failing Connects do not cause any row with EVENT_NAME
--echo # LIKE '%client_connection'
#===========================================================================
# Enable the following lines for debugging the check.
# Attention: socket_summary_by_instance_detail is after that rotten.
if(0)
{
--enable_info
eval
UPDATE mysqltest.socket_summary_by_instance_detail
SET statement = 'Connect boot '
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND statement LIKE ('Connect%root%')
AND EVENT_NAME LIKE ('%client_connection')
LIMIT 1;
--disable_info
}
let $part=
FROM mysqltest.socket_summary_by_instance_detail
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND statement LIKE ('Connect%boot%')
AND EVENT_NAME LIKE ('%client_connection');
if(`SELECT COUNT(*) $part`)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect that there are no rows because
--echo # - failing connects do not cause a row with "client_connection"
--echo # - all failing connects contain a user name LIKE '%boot%'
eval
SELECT
$column_list
$part;
let $print_details= 1;
}
--echo # 4.5.5 Successful Connects cause a new instance with EVENT_NAME
--echo # LIKE '%client_connection'
#===========================================================================
# Enable the following lines for debugging the check.
# Attention: socket_summary_by_instance_detail is after that rotten.
if(0)
{
--enable_info
DELETE
FROM mysqltest.socket_summary_by_instance_detail
WHERE EVENT_NAME LIKE ('%client_connection')
AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND statement LIKE ('Connect%root%')
LIMIT 1;
--disable_info
}
# - connects which should be successful have statement LIKE ('Connect%root%').
# - We try every type of Connect $loop_rounds times.
# Therefore we should find $loop_rounds rows with
# - EVENT_NAME LIKE ('%client_connection')
# AND
# - OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
# We do not want to count the entry of belonging to the default connection.
# AND
# - statement LIKE ('Connect%root%')
# The connects which should be successful.
#
let $my_rules=
COUNT(*) = $loop_rounds;
let $part=
FROM mysqltest.socket_summary_by_instance_detail
WHERE EVENT_NAME LIKE ('%client_connection')
AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND statement LIKE ('Connect%root%')
GROUP BY statement
HAVING NOT ( $my_rules );
if(`SELECT COUNT(*) $part`)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo # for GROUP BY statement
--echo #
eval
SELECT
$column_list
FROM mysqltest.socket_summary_by_instance_detail
WHERE EVENT_NAME LIKE ('%client_connection')
AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND statement IN
(SELECT statement
$part);
let $print_details= 1;
}
--echo # 4.6 Check the differences caused by Connects
--echo # - INSTANCES with an EVENT_NAME like server_tcpip_socket or
--echo # server_unix_socket are already checked
--echo # - the stability of results is already checked
--echo # So we con go with the results of the first run.
# Typical content of mysqltest.socket_summary_by_instance_detail
#
# eval
# SELECT $column_list
# FROM mysqltest.socket_summary_by_instance_detail
# WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
# AND EVENT_NAME LIKE ('%client_connection')
# AND statement LIKE ('Connect%')
# AND run = 1
# ORDER BY event_name,statement, run;
# CREAD TREAD BREAD CWRITE TWRITE BWRITE CMISC TMISC STATEMENT
# 4 6149616 79 3 34008480 117 3 38914128 Connect (con*,::ffff:127.0.0.1,root,,mysqltest,,)
# 4 7012368 84 3 10112256 117 2 43067376 Connect (con*,localhost,root,,mysqlsupertest,,)
# 4 7172880 79 3 10247688 117 2 40128000 Connect (con*,localhost,root,,mysqltest,,)
# 4 6706392 85 3 15509472 117 2 34851168 Connect (con*,localhost,root012345,,mysqltest,,)
# 4 10543632 89 3 10578744 117 2 39460872 Connect (con*,localhost,root0123456789,,mysqltest,,)
--echo # 4.6.1 The SUM_OF_BYTES_WRITE value depends on length of database
--echo # since the database name is written in OK packet.
--echo # Hence the value 2.
#========================================================================
let $my_rules= COUNT(DISTINCT SUM_NUMBER_OF_BYTES_WRITE) = 2;
let $part=
FROM mysqltest.socket_summary_by_instance_detail
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND EVENT_NAME LIKE ('%client_connection')
AND statement LIKE ('Connect%')
AND run = 1;
if(`SELECT NOT ( $my_rules) $part`)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo # for all Connects
--echo #
eval
SELECT
statement, SUM_NUMBER_OF_BYTES_WRITE
$part;
let $print_details= 1;
}
--echo # 4.6.2 The SUM_OF_BYTES_WRITE value hast to be > 100.
#============================================================
let $my_rules= SUM_NUMBER_OF_BYTES_WRITE > 100;
let $part=
FROM mysqltest.socket_summary_by_instance_detail
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND EVENT_NAME LIKE ('%client_connection')
AND statement LIKE ('Connect%')
AND NOT ( $my_rules )
AND run = 1;
if(`SELECT COUNT(*) $part`)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo # for all Connects
--echo #
eval
SELECT
statement, SUM_NUMBER_OF_BYTES_WRITE
$part;
let $print_details= 1;
}
--echo # 4.6.3 COUNT_READ, COUNT_WRITE and COUNT_MISC have to be to be > 0
#=========================================================================
let $my_rules=
COUNT_READ > 0 AND COUNT_WRITE > 0 AND COUNT_MISC > 0;
let $part=
FROM mysqltest.socket_summary_by_instance_detail
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND EVENT_NAME LIKE ('%client_connection')
AND statement LIKE ('Connect%')
AND NOT ( $my_rules )
AND run = 1;
if(`SELECT COUNT(*) $part`)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo # for all Connects
--echo #
eval
SELECT
statement, COUNT_READ, COUNT_WRITE, COUNT_MISC
$part;
let $print_details= 1;
}
--echo # 4.6.4 Checks based on comparison of results for connects
let $part0=
FROM mysqltest.socket_summary_by_instance_detail t1
JOIN mysqltest.socket_summary_by_instance_detail t2
USING (EVENT_NAME, run)
WHERE EVENT_NAME LIKE ('%client_connection')
AND run = 1
AND t2.OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND t1.OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin;
let $part1=
SELECT RPAD(statement,55,' ') AS STATEMENT,
LENGTH(statement), SUM_NUMBER_OF_BYTES_READ
FROM mysqltest.socket_summary_by_instance_detail
WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
AND EVENT_NAME LIKE ('%client_connection')
AND run = 1;
--echo # 4.6.4 The user name length affects the SUM_OF_BYTES_READ value
#======================================================================
# CREAD TREAD BREAD CWRITE TWRITE BWRITE CMISC TMISC STATEMENT
# 4 6706392 85 3 15509472 117 2 34851168 Connect (con*,localhost,root012345,,mysqltest,,)
# 4 10543632 89 3 10578744 117 2 39460872 Connect (con*,localhost,root0123456789,,mysqltest,,)
let $stmt2= Connect (con*,localhost,root0123456789,,mysqltest,,);
let $stmt1= Connect (con*,localhost,root012345,,mysqltest,,);
let $my_rules=
t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1');
if(`SELECT NOT ($my_rules)
$part0
AND t2.statement = '$stmt2'
AND t1.statement = '$stmt1'`)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo #
eval
$part1
AND statement IN('$stmt2','$stmt1');
let $print_details= 1;
}
--echo # 4.6.5 The database name length affects the SUM_OF_BYTES_READ value
#==========================================================================
# CREAD TREAD BREAD CWRITE TWRITE BWRITE CMISC TMISC STATEMENT
# 4 7012368 84 3 10112256 117 2 43067376 Connect (con*,localhost,root,,mysqlsupertest,,)
# 4 7172880 79 3 10247688 117 2 40128000 Connect (con*,localhost,root,,mysqltest,,)
let $stmt2= Connect (con*,localhost,root,,mysqlsupertest,,);
let $stmt1= Connect (con*,localhost,root,,mysqltest,,);
let $my_rules=
t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1');
if(`SELECT NOT ($my_rules)
$part0
AND t2.statement = '$stmt2'
AND t1.statement = '$stmt1'`)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo #
eval
$part1
AND statement IN('$stmt2','$stmt1');
let $print_details= 1;
}
--echo # 5. Check the impact of TRUNCATE on socket_summary_by_instance.
--echo # It must reset all counters.
#=======================================================================
# We do not need to check if the majority of counters is <> 0 because if
# we ever hit such a bad state than a lot of the preceding checks would
# have already failed and reported this.
TRUNCATE TABLE performance_schema.socket_summary_by_instance;
let $my_rules=
COUNT_STAR = 0 AND SUM_TIMER_WAIT = 0
AND
COUNT_READ = 0 AND SUM_TIMER_READ = 0 AND SUM_NUMBER_OF_BYTES_READ = 0
AND
COUNT_WRITE = 0 AND SUM_TIMER_WRITE = 0 AND SUM_NUMBER_OF_BYTES_WRITE = 0
AND
COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
if(`SELECT COUNT(*) FROM performance_schema.socket_summary_by_instance
WHERE NOT ( $my_rules )
AND OBJECT_INSTANCE_BEGIN = @default_object_instance_begin`)
{
--enable_query_log
--enable_result_log
--echo # The statistics looks suspicious.
--echo # We expect
--echo # $my_rules
--echo #
eval
SELECT
COUNT_STAR, SUM_TIMER_WAIT,
COUNT_READ,SUM_TIMER_READ,SUM_NUMBER_OF_BYTES_READ,
COUNT_WRITE,SUM_TIMER_WRITE,SUM_NUMBER_OF_BYTES_WRITE,
COUNT_MISC,SUM_TIMER_MISC
FROM performance_schema.socket_summary_by_instance
WHERE OBJECT_INSTANCE_BEGIN = @default_object_instance_begin;
}
if($print_details)
{
--enable_query_log
--enable_result_log
--horizontal_results
--echo # Dump detailed differences after - before statement execution
--echo # 1. The statement executing connection and hopefully no one else
SELECT @default_object_instance_begin;
SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
COUNT_READ, SUM_NUMBER_OF_BYTES_READ,
COUNT_WRITE, SUM_NUMBER_OF_BYTES_WRITE,
COUNT_MISC, statement
FROM mysqltest.socket_summary_by_instance_detail
WHERE EVENT_NAME LIKE '%client_connection%'
AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
ORDER BY statement, run;
--echo # 2. The connection default
SELECT EVENT_NAME,
COUNT_READ, SUM_NUMBER_OF_BYTES_READ,
COUNT_WRITE, SUM_NUMBER_OF_BYTES_WRITE,
COUNT_MISC, statement
FROM mysqltest.socket_summary_by_instance_detail
WHERE OBJECT_INSTANCE_BEGIN = @default_object_instance_begin
ORDER BY statement,run;
--echo # 3. The "server_unix_socket"
# WHERE OBJECT_INSTANCE_BEGIN = @default_object_instance_begin
SELECT EVENT_NAME,
COUNT_READ, SUM_NUMBER_OF_BYTES_READ,
COUNT_WRITE, SUM_NUMBER_OF_BYTES_WRITE,
COUNT_MISC, statement
FROM mysqltest.socket_summary_by_instance_detail
WHERE EVENT_NAME LIKE '%server_unix_socket%'
ORDER BY statement,run;
--echo # 4. The "server_tcpip_socket"
SELECT EVENT_NAME,
COUNT_READ, SUM_NUMBER_OF_BYTES_READ,
COUNT_WRITE, SUM_NUMBER_OF_BYTES_WRITE,
COUNT_MISC, statement
FROM mysqltest.socket_summary_by_instance_detail
WHERE EVENT_NAME LIKE '%server_tcpip_socket%'
ORDER BY statement,run;
--echo # 5. mysqltest.my_socket_summary_by_instance
--vertical_results
SELECT * FROM mysqltest.my_socket_summary_by_instance;
--horizontal_results
}
--echo # 6. Cleanup
#==================
# Cleanup
--disable_query_log
eval
UPDATE performance_schema.setup_timers
SET TIMER_NAME = '$wait_timer'
WHERE NAME = 'wait';
DROP SCHEMA mysqltest;
DROP SCHEMA mysqlsupertest;
--connection con1
--disconnect con1
--source include/wait_until_disconnected.inc
--connection default
--enable_query_log
|