mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 18:41:56 +01:00
b8f9f796ff
Compute binlog checksums (when enabled) already when writing events into the statement or transaction caches, where before it was done when the caches are copied to the real binlog file. This moves the checksum computation outside of holding LOCK_log, improving scalabitily. At stmt/trx cache write time, the final end_log_pos values are not known, so with this patch these will be set to 0. Events that are written directly to the binlog file (not through stmt/trx cache) keep the correct end_log_pos value. The GTID and COMMIT/XID events at the start and end of event groups are written directly, so the zero end_log_pos is only for events in the middle of event groups, which do not negatively affect replication. An option --binlog-legacy-event-pos, off by default, is provided to disable this behavior to provide backwards compatibility with any external applications that might rely on end_log_pos in events in the middle of event groups. Checksums cannot be pre-computed when binlog encryption is enabled, as encryption relies on correct end_log_pos to provide part of the nonce/IV. Checksum pre-computation is also disabled for WSREP/Galera, as it uses events differently in its write-sets and so on. Extending pre-computation of checksums to Galera where it makes sense could be added in a future patch. The current --binlog-checksum configuration is saved in binlog_cache_data at transaction start and used to pre-compute checksums in cache, if applicable. When the cache is later copied to the binlog, a check is made if the saved value still matches the configured global value; if so, the events are block-copied directly into the binlog file. If --binlog-checksum was changed during the transaction, events are re-written to the binlog file one-by-one and the checksums recomputed/discarded as appropriate. Reviewed-by: Monty <monty@mariadb.org> Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
35 lines
1.4 KiB
Text
35 lines
1.4 KiB
Text
CALL mtr.add_suppression("Error writing file 'master-bin'");
|
|
RESET MASTER;
|
|
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
|
|
INSERT INTO t1 VALUES(0);
|
|
SET @saved_dbug = @@SESSION.debug_dbug;
|
|
SET SESSION debug_dbug='+d,fail_binlog_write_1';
|
|
SET GLOBAL binlog_legacy_event_pos= 1;
|
|
INSERT INTO t1 VALUES(1);
|
|
ERROR HY000: Error writing file 'master-bin' (errno: 28 "No space left on device")
|
|
INSERT INTO t1 VALUES(2);
|
|
ERROR HY000: Error writing file 'master-bin' (errno: 28 "No space left on device")
|
|
SET SESSION debug_dbug=@saved_dbug;
|
|
SET GLOBAL binlog_legacy_event_pos= 0;
|
|
INSERT INTO t1 VALUES(3);
|
|
SELECT * FROM t1;
|
|
a
|
|
0
|
|
3
|
|
SHOW BINLOG EVENTS;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
BINLOG POS Format_desc 1 ENDPOS Server ver: #, Binlog ver: #
|
|
BINLOG POS Start_encryption 1 ENDPOS
|
|
BINLOG POS Gtid_list 1 ENDPOS []
|
|
BINLOG POS Binlog_checkpoint 1 ENDPOS master-bin.000001
|
|
BINLOG POS Gtid 1 ENDPOS GTID 0-1-1
|
|
BINLOG POS Query 1 ENDPOS use `test`; CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb
|
|
BINLOG POS Gtid 1 ENDPOS BEGIN GTID 0-1-2
|
|
BINLOG POS Query 1 ENDPOS use `test`; INSERT INTO t1 VALUES(0)
|
|
BINLOG POS Xid 1 ENDPOS COMMIT /* XID */
|
|
BINLOG POS Gtid 1 ENDPOS BEGIN GTID 0-1-3
|
|
BINLOG POS Gtid 1 ENDPOS BEGIN GTID 0-1-4
|
|
BINLOG POS Gtid 1 ENDPOS BEGIN GTID 0-1-5
|
|
BINLOG POS Query 1 ENDPOS use `test`; INSERT INTO t1 VALUES(3)
|
|
BINLOG POS Xid 1 ENDPOS COMMIT /* XID */
|
|
DROP TABLE t1;
|