| 1 |
# This test verifies that NDB Binlog injector events that overflow the |
| 2 |
# cache to disk are instrumented in the performance schema |
| 3 |
# tables. Also verifies that a warning is logged when NDB Binary Log |
| 4 |
# transactions had events that spilled to disk. |
| 5 |
|
| 6 |
-- source include/have_ndb.inc |
| 7 |
-- source include/have_binlog_format_mixed_or_row.inc |
| 8 |
|
| 9 |
# Save original value to allow restoring config before test end |
| 10 |
SET @save_ndb_log_cache_size = @@global.ndb_log_cache_size; |
| 11 |
SELECT @save_ndb_log_cache_size; |
| 12 |
|
| 13 |
# Configure lowest possible ndb binlog injector cache size to make it possible |
| 14 |
# to exceed the size and trigger a "disk spill" further down |
| 15 |
SET @@global.ndb_log_cache_size=4096; |
| 16 |
|
| 17 |
# Show that ndb_log_cache_size is a global variable |
| 18 |
--error ER_GLOBAL_VARIABLE |
| 19 |
SET SESSION ndb_log_cache_size=32768; |
| 20 |
|
| 21 |
-- let $cache_qry = SELECT COUNT_WRITE FROM performance_schema.file_summary_by_event_name WHERE event_name LIKE "%io_cache%" |
| 22 |
|
| 23 |
# Check configured values required by test |
| 24 |
SELECT @@global.ndb_log_cache_size; |
| 25 |
SELECT @@global.binlog_cache_size; |
| 26 |
SELECT @@global.binlog_stmt_cache_size; |
| 27 |
SELECT NAME, ENABLED FROM performance_schema.setup_instruments WHERE name LIKE "%file/sql/io_cache%"; |
| 28 |
|
| 29 |
CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB, lb LONGBLOB) ENGINE = NDB; |
| 30 |
|
| 31 |
-- echo # Insert small transactions that should NOT |
| 32 |
-- echo # trigger an IO_CACHE overflow |
| 33 |
-- echo # Insert ~2KiB of data per transaction |
| 34 |
|
| 35 |
-- let $before_writes = `$cache_qry` |
| 36 |
|
| 37 |
INSERT INTO t1 VALUES (1, repeat(0x41, 1024), repeat(0x42, 1024)); |
| 38 |
INSERT INTO t1 VALUES (2, repeat(0x41, 1024), repeat(0x42, 1024)); |
| 39 |
save_master_pos; |
| 40 |
|
| 41 |
-- let $after_writes= `$cache_qry` |
| 42 |
|
| 43 |
-- echo |
| 44 |
-- echo ## Verify there were no IO_CACHE write events |
| 45 |
-- echo |
| 46 |
|
| 47 |
-- let $assert_text= There were 0 writes to IO_CACHE |
| 48 |
-- let $assert_cond= $before_writes = $after_writes |
| 49 |
-- source include/assert.inc |
| 50 |
|
| 51 |
-- echo |
| 52 |
-- echo # Generate larger transactions to force an IO_CACHE |
| 53 |
-- echo # overflow and subsequent write to a temporary file. |
| 54 |
-- echo # Insert ~8KiB of data per transaction. |
| 55 |
|
| 56 |
-- let $before_writes = $after_writes |
| 57 |
|
| 58 |
SET SESSION AUTOCOMMIT=OFF; |
| 59 |
BEGIN; |
| 60 |
INSERT INTO t1 VALUES (3, repeat(0x41, 1024), repeat(0x42, 1024)); |
| 61 |
INSERT INTO t1 VALUES (4, repeat(0x41, 1024), repeat(0x42, 1024)); |
| 62 |
INSERT INTO t1 VALUES (5, repeat(0x41, 1024), repeat(0x42, 1024)); |
| 63 |
INSERT INTO t1 VALUES (6, repeat(0x41, 1024), repeat(0x42, 1024)); |
| 64 |
COMMIT; |
| 65 |
|
| 66 |
SET SESSION AUTOCOMMIT=ON; |
| 67 |
INSERT INTO t1 VALUES (7, repeat(0x41, 4096), repeat(0x42, 4096)); |
| 68 |
save_master_pos; |
| 69 |
|
| 70 |
-- let $after_writes = `$cache_qry` |
| 71 |
|
| 72 |
-- echo |
| 73 |
-- echo ## Verify IO_CACHE write events and that warnings were logged |
| 74 |
-- echo |
| 75 |
|
| 76 |
-- let $assert_text= There were >0 writes to IO_CACHE |
| 77 |
-- let $assert_cond= $before_writes < $after_writes |
| 78 |
-- source include/assert.inc |
| 79 |
|
| 80 |
--echo # Check that error log contains message indicating cache spill |
| 81 |
-- let $qry= SELECT count(DATA) as warnings FROM performance_schema.error_log WHERE SUBSYSTEM = "NDB" AND DATA REGEXP "Binary log cache data overflowed to disk" |
| 82 |
-- let $assert_text= Binary log cache data overflowed to disk |
| 83 |
-- let $assert_cond= [$qry, warnings, 1] >= 1 |
| 84 |
-- source include/assert.inc |
| 85 |
|
| 86 |
# The temporary file used for extending the cache in the above case can be |
| 87 |
# seen in performance_schema by quering the file_instances table, the file |
| 88 |
# has "ML" as file name prefix: |
| 89 |
# SELECT * FROM performance_schema.file_instances |
| 90 |
# WHERE EVENT_NAME = "wait/io/file/sql/io_cache"; |
| 91 |
# FILE_NAME EVENT_NAME OPEN_COUNT |
| 92 |
# /tmp/mysqld.1.1/MLfd=66 wait/io/file/sql/io_cache 1 |
| 93 |
--let $assert_cond = OPEN_COUNT >= 1 FROM performance_schema.file_instances WHERE EVENT_NAME = "wait/io/file/sql/io_cache" |
| 94 |
--let $assert_text = The IO_CACHE should spill to disk |
| 95 |
--source include/assert.inc |
| 96 |
|
| 97 |
# Supress the provoked message |
| 98 |
-- disable_query_log ONCE |
| 99 |
call mtr.add_suppression(".*Binary log cache data overflowed to disk.*"); |
| 100 |
|
| 101 |
--echo # |
| 102 |
--echo # Check that ndb_log_cache_size can be reconfigured at runtime and the |
| 103 |
--echo # large write which previously caused cache spill now fits. This is done |
| 104 |
--echo # by increasing cache size and doing the large write again. |
| 105 |
|
| 106 |
SET @@global.ndb_log_cache_size=1024*1024; |
| 107 |
BEGIN; |
| 108 |
INSERT INTO t1 VALUES (8, repeat(0x41, 1024), repeat(0x42, 1024)); |
| 109 |
INSERT INTO t1 VALUES (9, repeat(0x41, 1024), repeat(0x42, 1024)); |
| 110 |
INSERT INTO t1 VALUES (10, repeat(0x41, 1024), repeat(0x42, 1024)); |
| 111 |
INSERT INTO t1 VALUES (11, repeat(0x41, 1024), repeat(0x42, 1024)); |
| 112 |
INSERT INTO t1 VALUES (12, repeat(0x41, 1024), repeat(0x42, 1024)); |
| 113 |
INSERT INTO t1 VALUES (13, repeat(0x41, 1024), repeat(0x42, 1024)); |
| 114 |
INSERT INTO t1 VALUES (14, repeat(0x41, 1024), repeat(0x42, 1024)); |
| 115 |
INSERT INTO t1 VALUES (15, repeat(0x41, 1024), repeat(0x42, 1024)); |
| 116 |
COMMIT; |
| 117 |
--source suite/ndb/include/ndb_binlog_wait_own_changes.inc |
| 118 |
|
| 119 |
-- let $after_writes_with_large_cache = `$cache_qry` |
| 120 |
#echo after_writes_with_large_cache: $after_writes_with_large_cache; |
| 121 |
|
| 122 |
-- let $assert_text= Write with large cache didn't trigger cache overflow |
| 123 |
-- let $assert_cond= $after_writes = $after_writes_with_large_cache |
| 124 |
-- source include/assert.inc |
| 125 |
|
| 126 |
# Restore changed config to original value |
| 127 |
SET @@global.ndb_log_cache_size=@save_ndb_log_cache_size; |
| 128 |
|
| 129 |
|
| 130 |
-- echo |
| 131 |
|
| 132 |
DROP TABLE t1; |