| 1 |
--source include/have_debug.inc |
| 2 |
--source include/have_ndb.inc |
| 3 |
--source include/have_multi_ndb.inc |
| 4 |
|
| 5 |
# The "last_epoch" counter need to be reset after test to support --repeat |
| 6 |
--source include/force_restart.inc |
| 7 |
|
| 8 |
--echo ###################################################################### |
| 9 |
--echo # Bug#35199996 table map entry for certain table were logged in to the |
| 10 |
--echo # binlogs even though the log_replica_updates is disabled |
| 11 |
--echo ###################################################################### |
| 12 |
# |
| 13 |
# Before a Table_map event is injected in the Binlog, there are some |
| 14 |
# checks that need to be performed. One of these relies on a filtered |
| 15 |
# any-value, which is calculated from the accumulation of the |
| 16 |
# any-value on every event for a given table. The unfiltered value can |
| 17 |
# contain an indication that a change is not to be logged (no logging |
| 18 |
# bit) or that it comes from a replica (non zero server id). |
| 19 |
# |
| 20 |
# This test makes the Binlog injector to run a self-test functionality |
| 21 |
# that essentially creates a transaction against a NDB table, setting |
| 22 |
# up specific any-values. These any-values range from no logging bits |
| 23 |
# to server ids (mimicking replicas) that are inversed from one |
| 24 |
# another. Then it exports the generated Binlog, deletes the data and |
| 25 |
# imports once again. |
| 26 |
|
| 27 |
CREATE TABLE test_log_table_maps (id INT PRIMARY KEY, what VARCHAR(128)) ENGINE = NDB; |
| 28 |
SET @save_debug= @@GLOBAL.debug; |
| 29 |
SET @@GLOBAL.debug="+d,ndb_binlog_log_table_maps"; |
| 30 |
|
| 31 |
# Wait for dbug_log_table_maps to complete writing data to the table |
| 32 |
--let $ROWS = 16 |
| 33 |
while (`SELECT COUNT(*) < $ROWS FROM test_log_table_maps`) { |
| 34 |
sleep 0.1; |
| 35 |
} |
| 36 |
|
| 37 |
SET @@GLOBAL.debug= @save_debug; |
| 38 |
|
| 39 |
# Make sure we have logged everything up to date |
| 40 |
--save_master_pos |
| 41 |
|
| 42 |
--echo # Show data written |
| 43 |
SELECT * FROM test_log_table_maps ORDER BY id; |
| 44 |
|
| 45 |
--source include/show_binlog_events.inc |
| 46 |
|
| 47 |
--echo # Verify server1 Binlog changes |
| 48 |
--echo # Some rows are not logged because no-logging bit was set |
| 49 |
--let $table_name= test_log_table_maps |
| 50 |
--let $order_by= id |
| 51 |
--source ndb_binlog_verify_table.inc |
| 52 |
|
| 53 |
--echo [connection server2] |
| 54 |
--connection server2 |
| 55 |
# Make sure we have logged everything up to date |
| 56 |
--save_master_pos |
| 57 |
--source include/show_binlog_events.inc |
| 58 |
|
| 59 |
--echo # Verify server2 Binlog changes |
| 60 |
--echo # Additional rows are not logged because server2 does NOT log replica updates |
| 61 |
--let $table_name= test_log_table_maps |
| 62 |
--let $order_by= id |
| 63 |
--source ndb_binlog_verify_table.inc |
| 64 |
|
| 65 |
--echo [connection server1] |
| 66 |
--connection server1 |
| 67 |
DROP TABLE test_log_table_maps; |
| 68 |
|
| 69 |
|
| 70 |
--echo ###################################################################### |
| 71 |
--echo # Bug#37953883 table map entry is logged in binlog for create table |
| 72 |
--echo # statements when sql_log_bin is disabled for the session. |
| 73 |
--echo ###################################################################### |
| 74 |
|
| 75 |
# The Table_map event is only injected in the Binlog if the table had |
| 76 |
# any changes to be logged. This is seen from the any-value carried on |
| 77 |
# the data signal from SUMA. But while some changes in the table |
| 78 |
# result from more than 1 NdbOperation, the multiple any-values are |
| 79 |
# merged in the NdbApi and can be filtered. In the Ndb plugin this |
| 80 |
# filtering concludes, from the any-value carried, that the changes |
| 81 |
# can be: a replica applied update or NOT, or the no-logging flag was |
| 82 |
# set prior to the statement or NOT. Statements that include BLOB (and |
| 83 |
# the like) columns, result in subsequent NdbOperations to handle the |
| 84 |
# BLOBs (reads/writes/deletes) and these operations must include the |
| 85 |
# same any-value as the main NdbOperation of the statement. |
| 86 |
|
| 87 |
# This test sets a DBUG flag that turns on verification of Table_map |
| 88 |
# events without table updates to be logged (sql_log_bin=0) to assess |
| 89 |
# that no Table_map event must exist if there are no table |
| 90 |
# updates. This is specially important for subsequent operations, such |
| 91 |
# as BLOBs. |
| 92 |
|
| 93 |
--echo [connection server2] |
| 94 |
--connection server2 |
| 95 |
SET sql_log_bin=0; |
| 96 |
SET @save_debug= @@GLOBAL.debug; |
| 97 |
SET @@GLOBAL.debug="+d,ndb_binlog_verify_table_maps"; |
| 98 |
|
| 99 |
CREATE TABLE test_blob_log_table_maps (id INT PRIMARY KEY, b BLOB, lb LONGBLOB, lt LONGTEXT) ENGINE = NDB; |
| 100 |
|
| 101 |
INSERT INTO test_blob_log_table_maps VALUES (1, repeat("!", 512), repeat("@", 512), repeat("#", 512)), |
| 102 |
(2, repeat("!", 512), repeat("$", 512), repeat("&", 512)), |
| 103 |
(3, repeat("!", 512), repeat("%", 512), repeat("^", 512)), |
| 104 |
(4, repeat("!", 512), repeat("*", 512), repeat("~", 512)); |
| 105 |
--save_master_pos |
| 106 |
--echo # Should not abort |
| 107 |
|
| 108 |
SELECT id FROM test_blob_log_table_maps ORDER by id; |
| 109 |
|
| 110 |
UPDATE test_blob_log_table_maps |
| 111 |
SET lb = repeat("+", 256), lt = repeat("-", 128) |
| 112 |
WHERE id BETWEEN 1 and 4; |
| 113 |
--save_master_pos |
| 114 |
|
| 115 |
SELECT COUNT(lb), COUNT(lt) FROM test_blob_log_table_maps; |
| 116 |
|
| 117 |
DELETE FROM test_blob_log_table_maps; |
| 118 |
--save_master_pos |
| 119 |
|
| 120 |
SELECT COUNT(*) FROM test_blob_log_table_maps; |
| 121 |
|
| 122 |
--echo # Cleanup |
| 123 |
SET @@GLOBAL.debug = @save_debug; |
| 124 |
SET sql_log_bin=1; |
| 125 |
DROP TABLE test_blob_log_table_maps; |