1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-24 19:42:23 +03:00
Commit Graph

860 Commits

Author SHA1 Message Date
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
9d88c5b8b4 MDEV-31616 Problems with a stored function EMPTY() on upgrade to 10.6.
The IDENT_sys doesn't include keywords, so the function with the
keyword name can be created, but cannot be called.
Moving keywords to new rules keyword_func_sp_var_and_label and
keyword_func_sp_var_not_label so the functions with these
names are allowed.
2024-01-24 09:59:55 +04:00
35cc4b6c05 Merge 10.11 into 11.0 2024-01-22 10:10:50 +02:00
b3ca7fa089 Merge 10.6 into 10.11 2024-01-22 08:49:04 +02:00
21560bee9d Revert "MDEV-32899 InnoDB is holding shared dict_sys.latch while waiting for FOREIGN KEY child table lock on DDL"
This reverts commit 569da6a7ba,
commit 768a736174, and
commit ba6bf7ad9e
because of a regression that was filed as MDEV-33104.
2024-01-19 12:46:11 +02:00
d136169e39 Merge 11.3 into 11.4 2024-01-10 15:30:42 +02:00
af4f9daeb8 Merge 11.2 into 11.3 2024-01-10 15:30:21 +02:00
e4cb1e3295 Merge 11.1 into 11.2 2024-01-10 13:19:12 +02:00
c3a546e9e1 Merge 11.0 into 11.1 2024-01-10 12:45:44 +02:00
c2da55ac01 Merge 10.11 into 11.0 2024-01-10 12:42:56 +02:00
1eb11da3e5 Merge 10.6 into 10.11 2024-01-10 12:37:19 +02:00
c6c2a2b8d4 MDEV-33150 double-locking of LOCK_thd_kill in performance_schema.session_status
perfschema thread walker needs to take thread's LOCK_thd_kill to prevent
the thread from disappearing why it's being looked at.
But there's no need to lock it for the current thread.

In fact, it was harmful as some code down the stack might take
LOCK_thd_kill (e.g. set_killed() does it, and my_malloc_size_cb_func()
calls set_killed()). And it caused a bunch of mutexes being locked under
LOCK_thd_kill, which created problems later when my_malloc_size_cb_func()
called set_killed() at some unspecified point under some
random mutexes.
2024-01-09 16:05:08 +01:00
c44cac91ab MDEV-33031 Assertion failure upon reading from performance schema with binlog enabled
need to protect access to thread-local cache_mngr with LOCK_thd_data

technically only access from different threads has to be protected,
but this is the SHOW STATUS code path, so the difference is neglectable
2024-01-09 15:50:57 +01:00
c154aafe1a Merge remote-tracking branch '11.3' into 11.4 2023-12-21 15:40:55 +01:00
7f0094aac8 Merge branch '11.2' into 11.3 2023-12-21 02:14:59 +01:00
fef31a26f3 Merge branch '11.1' into 11.2 2023-12-20 23:43:05 +01:00
7a5448f8da Merge branch '11.0' into 11.1 2023-12-19 20:11:54 +01:00
8c8bce05d2 Merge branch '10.11' into 11.0 2023-12-19 15:53:18 +01:00
fd0b47f9d6 Merge branch '10.6' into 10.11 2023-12-18 11:19:04 +01:00
aed9c656a9 MDEV-32101 CREATE PACKAGE [BODY] for sql_mode=DEFAULT
This patch adds PACKAGE support with SQL/PSM dialect for sql_mode=DEFAULT:

- CREATE PACKAGE
- DROP PACKAGE
- CREATE PACKAGE BODY
- DROP PACKAGE BODY
- Package function and procedure invocation from outside of the package:
    -- using two step identifiers
    SELECT pkg.f1();
    CALL pkg.p1()

    -- using three step identifiers
    SELECT db.pkg.f1();
    CALL db.pkg.p1();

This is a non-standard MariaDB extension.

However, later this code can be used to implement
the SQL Standard and DB2 dialects of CREATE MODULE.
2023-12-18 13:34:55 +04:00
e95bba9c58 Merge branch '10.5' into 10.6 2023-12-17 11:20:43 +01:00
485773adce check_digest() tests
DIGEST independed testing for performance_schema events.
2023-12-07 14:27:42 +03:00
98a39b0c91 Merge branch '10.4' into 10.5 2023-12-02 01:02:50 +01:00
96250c8269 Merge 11.1 into 11.2
Fix old_mode flags conflict between OLD_MODE_NO_NULL_COLLATION_IDS
and OLD_MODE_LOCK_ALTER_TABLE_COPY.

Both flags used to be 1 << 6, now OLD_MODE_LOCK_ALTER_TABLE_COPY changed
to be 1 << 7
2023-11-30 22:12:31 +01:00
2b40f8d2ca Merge branch '11.0' into 11.1 2023-11-30 19:13:30 +01:00
0fb897b081 Merge 10.11 into 11.0 2023-11-30 16:20:47 +02:00
6d0bcfc4b9 Merge 10.6 into 10.11 2023-11-30 13:03:59 +02:00
ba6bf7ad9e MDEV-32899 instrumentation
In debug builds, let us declare dict_sys.latch as index_lock instead of
srw_lock, so that we will benefit from the full tracking of lock ownership.

lock_table_for_trx(): Assert that the current thread is not holding
dict_sys.latch. If the dict_sys.unfreeze() call were moved to the end of
lock_table_children(), this assertion would fail in the test innodb.innodb
and many other tests that use FOREIGN KEY.
2023-11-29 10:48:10 +02:00
02701a8430 Merge 11.2 into 11.3 2023-11-28 11:19:50 +02:00
0d29f3759c Merge 11.1 into 11.2 2023-11-28 11:19:06 +02:00
7317aadeea perfschema.threads_mysql sporadic failures
wait a bit more thoroughly for event scheduler to be fully started
2023-11-25 10:33:31 +01:00
edc478847b Merge 11.0 into 11.1 2023-11-24 15:58:35 +02:00
5b6134b040 Merge 10.11 into 11.0 2023-11-24 11:20:56 +02:00
90d968dab9 Merge 10.6 into 10.11 2023-11-20 10:08:19 +02:00
52ca2e65af Merge 10.5 into 10.6 2023-11-15 14:10:21 +02:00
34272bd6a5 Merge branch '11.2' into 11.3 2023-11-14 18:33:03 +01:00
0427c4739e Merge tag '11.1' into 11.2
MariaDB 11.1.3 release
2023-11-14 18:28:37 +01:00
9f83a8822f Merge branch '10.5' into mariadb-10.5.23 2023-11-14 08:41:23 +01:00
0f5613a25f Merge branch '11.0' into 11.1 2023-11-08 18:03:08 +01:00
48af85db21 Merge branch '10.11' into 11.0 2023-11-08 17:09:44 +01:00
fecd78b837 Merge branch '10.10' into 10.11 2023-11-08 16:46:47 +01:00
04d9a46c41 Merge branch '10.6' into 10.10 2023-11-08 16:23:30 +01:00
b83c379420 Merge branch '10.5' into 10.6 2023-11-08 15:57:05 +01:00
6cfd2ba397 Merge branch '10.4' into 10.5 2023-11-08 12:59:00 +01:00
c68620df48 Fix random test failures in testcase perfschema.mdl_func
The test case can get extra rows in its output from table
performance_schema.table_handles, left there by an earlier test case (for
example main.long_unique_delayed). So force a server restart at the
beginning of the test.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2023-11-04 20:40:31 +01:00
7b842f1536 Merge 11.2 into 11.3 2023-10-27 10:48:29 +03:00
d0f8dfbcf0 Merge branch '11.1' into 11.2 2023-10-27 18:11:56 +11:00
0c1bf5e247 MDEV-27247: Add keywords "SQL_BEFORE_GTIDS" and "SQL_AFTER_GTIDS" for START SLAVE UNTIL
New Feature:
============
This patch extends the START SLAVE UNTIL command with options
SQL_BEFORE_GTIDS and SQL_AFTER_GTIDS to allow user control of
whether the replica stops before or after a provided GTID state. Its
syntax is:

START SLAVE UNTIL (SQL_BEFORE_GTIDS|SQL_AFTER_GTIDS)=”<gtid_list>”

When providing SQL_BEFORE_GTIDS=”<gtid_list>”, for each domain
specified in the gtid_list, the replica will execute transactions up
to the GTID found, and immediately stop processing events in that
domain (without executing the transaction of the specified GTID).
Once all domains have stopped, the replica will stop. Events
originating from domains that are not specified in the list are not
replicated.

START SLAVE UNTIL SQL_AFTER_GTIDS=”<gtid_list>” is an alias to the
default behavior of START SLAVE UNTIL master_gtid_pos=”<gtid_list>”.
That is, the replica will only execute transactions originating from
domain ids provided in the list, and will stop once all transactions
provided in the UNTIL list have all been executed.

Example:
=========
If a primary server has a binary log consisting of the following GTIDs:

0-1-1
1-1-1
0-1-2
1-1-2
0-1-3
1-1-3

If a fresh replica (i.e. one with an empty GTID position,
@@gtid_slave_pos='') is started with SQL_BEFORE_GTIDS, i.e.

START SLAVE UNTIL SQL_BEFORE_GTIDS=”1-1-2”

The resulting gtid_slave_pos of the replica will be “1-1-1”.
This is because the replica will execute only events from domain 1
until it sees the transaction with sequence number 2, and
immediately stop without executing it.

If the replica is started with SQL_AFTER_GTIDS, i.e.

START SLAVE UNTIL SQL_AFTER_GTIDS=”1-1-2”

then the resulting gtid_slave_pos of the replica will be “1-1-2”.
This is because it will only execute events from domain 1 until it
has executed the provided GTID.

Reviewed By:
============
Kristian Nielson <knielsen@knielsen-hq.org>
2023-10-23 06:40:05 -06:00
65700edb26 Merge 10.10 into 10.11 2023-10-19 14:50:42 +03:00
c92d06748a Merge 10.6 into 10.10 2023-10-19 14:35:31 +03:00