1include/install_replication_observers_example.inc 2include/master-slave.inc 3Warnings: 4Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. 5Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. 6[connection master] 7# 8# Set up test 9# 10CREATE TABLE t1 (c1 INT PRIMARY KEY) Engine=InnoDB; 11# 12# Case 1. This will cause the before_commit hook to fail. As a 13# consequence, the whole transaction shall fail. 14# 15SET @debug_saved= @@GLOBAL.DEBUG; 16SET @@GLOBAL.DEBUG= '+d,force_error_on_before_commit_listener'; 17SET SESSION sql_log_bin= 0; 18call mtr.add_suppression("Run function 'before_commit' in plugin"); 19SET SESSION sql_log_bin= 1; 20BEGIN; 21INSERT t1 VALUES(1); 22COMMIT; 23ERROR HY000: Error on observer while running replication hook 'before_commit'. 24INSERT t1 VALUES(2); 25ERROR HY000: Error on observer while running replication hook 'before_commit'. 26include/assert.inc [GTID_EXECUTED must remain the same] 27include/assert.inc [Table must remain empty] 28include/sync_slave_sql_with_master.inc 29include/assert.inc [GTID_EXECUTED must remain the same] 30include/assert.inc [Table must remain empty] 31SET @@GLOBAL.DEBUG=''; 32# 33# Case 2. This will force the Transaction Context to report an invalid 34# transaction certification outcome, 35# 36SET @@GLOBAL.DEBUG= '+d,force_invalid_certification_outcome'; 37SET SESSION sql_log_bin= 0; 38call mtr.add_suppression("Plugin replication_observers_example reported: 'Unable to update transaction context service on server, thread_id:.*"); 39SET SESSION sql_log_bin= 1; 40BEGIN; 41INSERT t1 VALUES(1); 42COMMIT; 43ERROR HY000: Error on observer while running replication hook 'before_commit'. 44INSERT t1 VALUES(2); 45ERROR HY000: Error on observer while running replication hook 'before_commit'. 46include/assert.inc [GTID_EXECUTED must remain the same] 47include/assert.inc [Table must remain empty] 48include/sync_slave_sql_with_master.inc 49include/assert.inc [GTID_EXECUTED must remain the same] 50include/assert.inc [Table must remain empty] 51SET @@GLOBAL.DEBUG=''; 52# 53# Case 3. This will force the Transaction Context to report an negative 54# transaction certification outcome, 55# 56SET @@GLOBAL.DEBUG= '+d,force_negative_certification_outcome'; 57BEGIN; 58INSERT t1 VALUES(1); 59COMMIT; 60ERROR HY000: Plugin instructed the server to rollback the current transaction. 61INSERT t1 VALUES(2); 62ERROR HY000: Plugin instructed the server to rollback the current transaction. 63include/assert.inc [GTID_EXECUTED must remain the same] 64include/assert.inc [Table must remain empty] 65include/sync_slave_sql_with_master.inc 66include/assert.inc [GTID_EXECUTED must remain the same] 67include/assert.inc [Table must remain empty] 68SET @@GLOBAL.DEBUG=''; 69# 70# Case 4. This will force the Transaction Context to report a valid 71# outcome without generating a GTID. 72# 73SET @@GLOBAL.DEBUG= '+d,force_positive_certification_outcome_without_gtid'; 74BEGIN; 75INSERT t1 VALUES(1); 76COMMIT; 77INSERT t1 VALUES(2); 78SELECT * FROM t1;; 79c1 1 80c1 2 81include/assert.inc [At this point we should have 2 successful operations] 82include/sync_slave_sql_with_master.inc 83include/assert.inc [At this point we should have 2 successful operations] 84SET @@GLOBAL.DEBUG=''; 85# 86# Case 5. This will force the Transaction Context to report a valid 87# outcome generating a GTID 88# 89SET @@GLOBAL.DEBUG= '+d,force_positive_certification_outcome_with_gtid'; 90BEGIN; 91INSERT t1 VALUES(3); 92COMMIT; 93INSERT t1 VALUES(4); 94SELECT * FROM t1;; 95c1 1 96c1 2 97c1 3 98c1 4 99include/assert.inc [GTID_EXECUTED must contain all GTIDs with the server id and with the fake id] 100include/sync_slave_sql_with_master.inc 101include/assert.inc [GTID_EXECUTED must contain all GTIDs with the server id and with the fake id] 102# 103# Clean up 104# 105SET @@GLOBAL.DEBUG= @debug_saved; 106DROP TABLE t1; 107include/rpl_end.inc 108include/uninstall_replication_observers_example.inc 109End of test 110