1
0
mirror of https://github.com/MariaDB/server.git synced 2025-09-11 05:52:26 +03:00
Files
mariadb/mysql-test/suite/rpl/t/rpl_gtid_glle_no_terminate.test
Kristian Nielsen d039346a7a MDEV-4991: GTID binlog indexing
Improve the performance of slave connect using B+-Tree indexes on each binlog
file. The index allows fast lookup of a GTID position to the corresponding
offset in the binlog file, as well as lookup of a position to find the
corresponding GTID position.

This eliminates a costly sequential scan of the starting binlog file
to find the GTID starting position when a slave connects. This is
especially costly if the binlog file is not cached in memory (IO
cost), or if it is encrypted or a lot of slaves connect simultaneously
(CPU cost).

The size of the index files is generally less than 1% of the binlog data, so
not expected to be an issue.

Most of the work writing the index is done as a background task, in
the binlog background thread. This minimises the performance impact on
transaction commit. A simple global mutex is used to protect index
reads and (background) index writes; this is fine as slave connect is
a relatively infrequent operation.

Here are the user-visible options and status variables. The feature is on by
default and is expected to need no tuning or configuration for most users.

binlog_gtid_index
  On by default. Can be used to disable the indexes for testing purposes.

binlog_gtid_index_page_size (default 4096)
  Page size to use for the binlog GTID index. This is the size of the nodes
  in the B+-tree used internally in the index. A very small page-size (64 is
  the minimum) will be less efficient, but can be used to stress the
  BTree-code during testing.

binlog_gtid_index_span_min (default 65536)
  Control sparseness of the binlog GTID index. If set to N, at most one
  index record will be added for every N bytes of binlog file written.
  This can be used to reduce the number of records in the index, at
  the cost only of having to scan a few more events in the binlog file
  before finding the target position

Two status variables are available to monitor the use of the GTID indexes:

  Binlog_gtid_index_hit
  Binlog_gtid_index_miss

The "hit" status increments for each successful lookup in a GTID index.
The "miss" increments when a lookup is not possible. This indicates that the
index file is missing (eg. binlog written by old server version
without GTID index support), or corrupt.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2024-01-27 12:09:54 +01:00

74 lines
2.1 KiB
Plaintext

#
# Purpose:
# If a fake Glle event follows a Gtid event, we need to ensure the rest of
# the group should not terminate at the Glle event. MDEV-28550 revealed that
# a Glle would terminate the event and upon reconnect, the DDL would be lost.
#
# Methodology:
# Force the primary to send a fake GLLE event after a GTID on a "reconnect"
# and ensure that both 1) the replica does not error, and 2) the original
# command within the GTID is executed.
#
# References:
# MDEV-28550: improper handling of replication event group that contains Gtid_log_list_event
--source include/master-slave.inc
# Independent of binlog format
--source include/have_binlog_format_statement.inc
--connection slave
--source include/stop_slave.inc
CHANGE MASTER TO MASTER_USE_GTID=slave_pos;
--echo #
--echo # Initialize test data
--connection master
--source include/wait_for_binlog_checkpoint.inc
create table t1 (a int);
SET @@session.server_id= 3;
create table t2 (a int);
--source include/save_master_gtid.inc
--echo #
--echo # Have the replica "reconnect" and the primary will send Gtid, Glle, DDL
--connection slave
eval set global gtid_slave_pos="0-3-1";
--source include/start_slave.inc
--source include/sync_with_master_gtid.inc
--echo #
--echo # Ensure that the replica did not error
connection slave;
--source include/sync_with_master_gtid.inc
let $error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1);
--echo Last_SQL_Error = $error
let $errno= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
--echo Last_SQL_Errno = $errno
--echo #
--echo # Ensure that the primary sent a Glle after a Gtid event
let $binlog_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);
let $binlog_start= $relaylog_start;
let $binlog_limit=0,10;
--source include/show_relaylog_events.inc
--echo #
--echo # Ensure the DDL was executed on the replica
if (!`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`)
{
die "t2 should exist on slave";
}
--echo #
--echo # Cleanup
--echo # t1 does not make it to the replica
--connection master
set sql_log_bin=0;
DROP TABLE t1;
set sql_log_bin=1;
DROP TABLE t2;
--source include/rpl_end.inc