mirror of
https://github.com/MariaDB/server.git
synced 2025-10-27 05:56:07 +03:00
Problem: ======= This patch addresses two issues: 1. An incident event can be incorrectly reported for transactions which are rolled back successfully. That is, an incident event should only be generated for failed “non-transactional transactions” (i.e., those which modify non-transactional tables) because they cannot be rolled back. 2. When the mariadb slave (error) stops at receiving the incident event there's no description of what led to it. Neither in the event nor in the master's error log. Solution: ======== Before reporting an incident event for a transaction, first validate that it is “non-transactional” (i.e. cannot be safely rolled back). To determine if a transaction is non-transactional, lex->stmt_accessed_table(LEX::STMT_WRITES_NON_TRANS_TABLE) is used because it is set previously in THD::decide_logging_format(). Additionally, when an incident event is written, write an error message to the server’s error log to indicate the underlying issue. Reviewed by: =========== Andrei Elkin <andrei.elkin@mariadb.com>
127 lines
4.7 KiB
Plaintext
127 lines
4.7 KiB
Plaintext
#
|
|
# Initialization
|
|
#
|
|
DROP TABLE IF EXISTS t1, t2;
|
|
DROP FUNCTION IF EXISTS f1;
|
|
DROP FUNCTION IF EXISTS f2;
|
|
DROP PROCEDURE IF EXISTS p1;
|
|
DROP PROCEDURE IF EXISTS p2;
|
|
DROP TRIGGER IF EXISTS tr1;
|
|
DROP TRIGGER IF EXISTS tr2;
|
|
DROP VIEW IF EXISTS v1, v2;
|
|
call mtr.add_suppression("Write to binary log failed: Error writing file*");
|
|
#
|
|
# Test injecting binlog write error when executing queries
|
|
#
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
|
|
CREATE TABLE t1 (a INT);
|
|
CREATE TABLE t1 (a INT);
|
|
ERROR HY000: Error writing file 'master-bin' ((errno: #)
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
INSERT INTO t1 VALUES (1),(2),(3);
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
|
|
INSERT INTO t1 VALUES (4),(5),(6);
|
|
INSERT INTO t1 VALUES (4),(5),(6);
|
|
ERROR HY000: Error writing file 'master-bin' ((errno: #)
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
|
|
UPDATE t1 set a=a+1;
|
|
UPDATE t1 set a=a+1;
|
|
ERROR HY000: Error writing file 'master-bin' ((errno: #)
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
|
|
DELETE FROM t1;
|
|
DELETE FROM t1;
|
|
ERROR HY000: Error writing file 'master-bin' ((errno: #)
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
|
|
CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t1 VALUES (new.a + 100);
|
|
CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t1 VALUES (new.a + 100);
|
|
ERROR HY000: Error writing file 'master-bin' ((errno: #)
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
|
|
DROP TRIGGER tr1;
|
|
DROP TRIGGER tr1;
|
|
ERROR HY000: Error writing file 'master-bin' ((errno: #)
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
|
|
ALTER TABLE t1 ADD (b INT);
|
|
ALTER TABLE t1 ADD (b INT);
|
|
ERROR HY000: Error writing file 'master-bin' ((errno: #)
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
|
|
CREATE VIEW v1 AS SELECT a FROM t1;
|
|
CREATE VIEW v1 AS SELECT a FROM t1;
|
|
ERROR HY000: Error writing file 'master-bin' ((errno: #)
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
|
|
DROP VIEW v1;
|
|
DROP VIEW v1;
|
|
ERROR HY000: Error writing file 'master-bin' ((errno: #)
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
|
|
CREATE PROCEDURE p1(OUT rows_cnt INT) SELECT count(*) INTO rows_cnt FROM t1;
|
|
CREATE PROCEDURE p1(OUT rows_cnt INT) SELECT count(*) INTO rows_cnt FROM t1;
|
|
ERROR HY000: Error writing file 'master-bin' ((errno: #)
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
|
|
DROP PROCEDURE p1;
|
|
DROP PROCEDURE p1;
|
|
ERROR HY000: Error writing file 'master-bin' ((errno: #)
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
|
|
DROP TABLE t1;
|
|
DROP TABLE t1;
|
|
ERROR HY000: Error writing file 'master-bin' ((errno: #)
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
|
|
CREATE FUNCTION f1() RETURNS INT return 1;
|
|
CREATE FUNCTION f1() RETURNS INT return 1;
|
|
ERROR HY000: Error writing file 'master-bin' ((errno: #)
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
|
|
DROP FUNCTION f1;
|
|
DROP FUNCTION f1;
|
|
ERROR HY000: Error writing file 'master-bin' ((errno: #)
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
|
|
CREATE USER user1;
|
|
CREATE USER user1;
|
|
ERROR HY000: Error writing file 'master-bin' ((errno: #)
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
|
|
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1;
|
|
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1;
|
|
ERROR HY000: Error writing file 'master-bin' ((errno: #)
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
|
|
DROP USER user1;
|
|
DROP USER user1;
|
|
ERROR HY000: Error writing file 'master-bin' ((errno: #)
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
#
|
|
# Cleanup
|
|
#
|
|
DROP TABLE IF EXISTS t1, t2;
|
|
DROP FUNCTION IF EXISTS f1;
|
|
DROP PROCEDURE IF EXISTS p1;
|
|
DROP TRIGGER IF EXISTS tr1;
|
|
DROP VIEW IF EXISTS v1, v2;
|