From cca4e14f9b354d9428df834f3c98eb274f723717 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Fri, 19 Nov 2021 12:17:14 +0300 Subject: Make the Optimizer Trace of reqular query and PS EXECUTE be identical Print this piece when we've just made the choice to convert to semi-join. Also, print it when we've already made that choice before: transformation": { "select_id": 2, "from": "IN (SELECT)", "to": "semijoin", "chosen": true } --- sql/opt_subselect.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index cef6cd9c160..e0c1d6dac4a 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -714,6 +714,15 @@ int check_and_do_in_subquery_rewrites(JOIN *join) if (arena) thd->restore_active_arena(arena, &backup); in_subs->is_registered_semijoin= TRUE; + } + + /* + Print the transformation into trace. Do it when we've just set + is_registered_semijoin=TRUE above, and also do it when we've already + had it set. + */ + if (in_subs->is_registered_semijoin) + { OPT_TRACE_TRANSFORM(thd, trace_wrapper, trace_transform, select_lex->select_number, "IN (SELECT)", "semijoin"); -- cgit v1.2.1 From 4ebac0fc8664708639babfc0e352f736fbf09451 Mon Sep 17 00:00:00 2001 From: Martin Beck Date: Sat, 20 Nov 2021 14:22:25 +1100 Subject: MDEV-27088: Server crash on ARM (WMM architecture) due to missing barriers in lf-hash (10.5) MariaDB server crashes on ARM (weak memory model architecture) while concurrently executing l_find to load node->key and add_to_purgatory to store node->key = NULL. l_find then uses key (which is NULL), to pass it to a comparison function. The specific problem is the out-of-order execution that happens on a weak memory model architecture. Two essential reorderings are possible, which need to be prevented. a) As l_find has no barriers in place between the optimistic read of the key field lf_hash.cc#L117 and the verification of link lf_hash.cc#L124, the processor can reorder the load to happen after the while-loop. In that case, a concurrent thread executing add_to_purgatory on the same node can be scheduled to store NULL at the key field lf_alloc-pin.c#L253 before key is loaded in l_find. b) A node is marked as deleted by a CAS in l_delete lf_hash.cc#L247 and taken off the list with an upfollowing CAS lf_hash.cc#L252. Only if both CAS succeed, the key field is written to by add_to_purgatory. However, due to a missing barrier, the relaxed store of key lf_alloc-pin.c#L253 can be moved ahead of the two CAS operations, which makes the value of the local purgatory list stored by add_to_purgatory visible to all threads operating on the list. As the node is not marked as deleted yet, the same error occurs in l_find. This change three accesses to be atomic. * optimistic read of key in l_find lf_hash.cc#L117 * read of link for verification lf_hash.cc#L124 * write of key in add_to_purgatory lf_alloc-pin.c#L253 Reviewers: Sergei Vojtovich, Sergei Golubchik Fixes: MDEV-23510 / d30c1331a18d875e553f3fcf544997e4f33fb943 --- mysys/lf_alloc-pin.c | 5 +++-- mysys/lf_hash.cc | 14 +++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c index 2162e1771ba..33480289d94 100644 --- a/mysys/lf_alloc-pin.c +++ b/mysys/lf_alloc-pin.c @@ -250,8 +250,9 @@ static int ptr_cmp(void **a, void **b) #define add_to_purgatory(PINS, ADDR) \ do \ { \ - *(void **)((char *)(ADDR)+(PINS)->pinbox->free_ptr_offset)= \ - (PINS)->purgatory; \ + my_atomic_storeptr_explicit( \ + (void **)((char *)(ADDR)+(PINS)->pinbox->free_ptr_offset), \ + (PINS)->purgatory, MY_MEMORY_ORDER_RELEASE); \ (PINS)->purgatory= (ADDR); \ (PINS)->purgatory_count++; \ } while (0) diff --git a/mysys/lf_hash.cc b/mysys/lf_hash.cc index bc3504bc0dd..c8f2e3f456f 100644 --- a/mysys/lf_hash.cc +++ b/mysys/lf_hash.cc @@ -103,8 +103,9 @@ retry: do { /* PTR() isn't necessary below, head is a dummy node */ cursor->curr= my_assume_aligned((LF_SLIST *)(*cursor->prev)); lf_pin(pins, 1, cursor->curr); - } while (my_atomic_loadptr((void **)my_assume_aligned(cursor->prev)) != cursor->curr && - LF_BACKOFF()); + } while (my_atomic_loadptr( + (void **)my_assume_aligned(cursor->prev)) + != cursor->curr && LF_BACKOFF()); for (;;) { if (unlikely(!cursor->curr)) @@ -114,14 +115,17 @@ retry: cur_keylen= cursor->curr->keylen; /* The key element needs to be aligned, not necessary what it points to */ my_assume_aligned(&cursor->curr->key); - cur_key= cursor->curr->key; + cur_key= (const uchar *) my_atomic_loadptr_explicit((void **) &cursor->curr->key, + MY_MEMORY_ORDER_ACQUIRE); do { /* attempting to my_assume_aligned onlink below broke the implementation */ - link= cursor->curr->link; + link= (intptr) my_atomic_loadptr_explicit((void **) &cursor->curr->link, + MY_MEMORY_ORDER_RELAXED); cursor->next= my_assume_aligned(PTR(link)); lf_pin(pins, 0, cursor->next); - } while (link != cursor->curr->link && LF_BACKOFF()); + } while (link != (intptr) my_atomic_loadptr((void *volatile *) &cursor->curr->link) + && LF_BACKOFF()); if (!DELETED(link)) { -- cgit v1.2.1 From d7b37de9360d2db213dbcd95d2231f53ed00208d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Sat, 27 Nov 2021 09:56:56 +0200 Subject: Fix bad galera tests * galera_kill_applier : we should make sure that node has correct number of wsrep appliers * galera_bad_wsrep_new_cluster: This test restarts both nodes, so it is bad on mtr. Make sure it is run alone * galera_update_limit : Make sure we have PK when needed galera_as_slave_replay : bf abort was not consistent * galera_unicode_pk : Add wait_conditions so that all nodes are part of cluster and DDL and INSERT has replicated before any further operations are done. * galera_bf_abort_at_after_statement : Add wait_conditions to make sure all nodes are part of cluster and that DDL and INSERT has replicated. Make sure we reset DEBUG_SYNC. --- mysql-test/suite/galera/disabled.def | 2 + .../suite/galera/r/galera_as_slave_replay.result | 41 +------------ .../r/galera_bf_abort_at_after_statement.result | 2 + .../suite/galera/r/galera_kill_applier.result | 10 +++- mysql-test/suite/galera/r/galera_unicode_pk.result | 1 + .../suite/galera/r/galera_update_limit.result | 4 +- .../suite/galera/t/galera_as_slave_replay.cnf | 2 + .../suite/galera/t/galera_as_slave_replay.test | 68 ++-------------------- .../galera/t/galera_bad_wsrep_new_cluster.cnf | 7 +++ .../t/galera_bf_abort_at_after_statement.cnf | 7 +++ .../t/galera_bf_abort_at_after_statement.test | 12 ++++ mysql-test/suite/galera/t/galera_kill_applier.cnf | 7 +++ mysql-test/suite/galera/t/galera_kill_applier.test | 12 +++- mysql-test/suite/galera/t/galera_sp_bf_abort.cnf | 7 +++ mysql-test/suite/galera/t/galera_unicode_pk.cnf | 7 +++ mysql-test/suite/galera/t/galera_unicode_pk.test | 11 ++++ mysql-test/suite/galera/t/galera_update_limit.cnf | 7 +++ mysql-test/suite/galera/t/galera_update_limit.test | 5 +- 18 files changed, 100 insertions(+), 112 deletions(-) create mode 100644 mysql-test/suite/galera/t/galera_bad_wsrep_new_cluster.cnf create mode 100644 mysql-test/suite/galera/t/galera_bf_abort_at_after_statement.cnf create mode 100644 mysql-test/suite/galera/t/galera_kill_applier.cnf create mode 100644 mysql-test/suite/galera/t/galera_sp_bf_abort.cnf create mode 100644 mysql-test/suite/galera/t/galera_unicode_pk.cnf create mode 100644 mysql-test/suite/galera/t/galera_update_limit.cnf diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index e4210734f5e..f1eb959e5bd 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -37,3 +37,5 @@ mysql-wsrep#198 : MDEV-24446: galera.mysql-wsrep#198 MTR failed: query 'reap' fa partition : MDEV-19958 Galera test failure on galera.partition query_cache: MDEV-15805 Test failure on galera.query_cache versioning_trx_id: MDEV-18590: galera.versioning_trx_id: Test failure: mysqltest: Result content mismatch +galera_ssl_mode_server : Certificate CA mismatch +galera_bf_abort_at_after_statement : Unstable diff --git a/mysql-test/suite/galera/r/galera_as_slave_replay.result b/mysql-test/suite/galera/r/galera_as_slave_replay.result index d81795eeed9..05bfeed8f01 100644 --- a/mysql-test/suite/galera/r/galera_as_slave_replay.result +++ b/mysql-test/suite/galera/r/galera_as_slave_replay.result @@ -60,44 +60,6 @@ f1 f2 2 b 3 c SET DEBUG_SYNC = "RESET"; -# -# test phase with real abort -# -connection node_3; -set binlog_format=ROW; -insert into t1 values (4, 'd'); -SET AUTOCOMMIT=ON; -START TRANSACTION; -UPDATE t1 SET f2 = 'd' WHERE f1 = 3; -connection node_2a; -SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_enter_sync'; -SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb"; -connection node_1; -UPDATE test.t1 SET f2 = 'e' WHERE f1 = 3; -connection node_3; -COMMIT; -connection node_2a; -SET GLOBAL debug_dbug = ""; -SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; -connection node_2a; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_enter_sync'; -SET DEBUG_SYNC = "RESET"; -connection node_2a; -set session wsrep_sync_wait=0; -SELECT * from test.t1; -f1 f2 -1 a -2 b -3 e -4 d -connection node_1; -SELECT * from test.t1; -f1 f2 -1 a -2 b -3 e -4 d connection node_2a; STOP SLAVE; RESET SLAVE; @@ -105,3 +67,6 @@ DROP TABLE t1; connection node_3; DROP TABLE t1; RESET MASTER; +connection node_1; +disconnect node_2a; +disconnect node_3; diff --git a/mysql-test/suite/galera/r/galera_bf_abort_at_after_statement.result b/mysql-test/suite/galera/r/galera_bf_abort_at_after_statement.result index e44a925baf4..f6f0803227f 100644 --- a/mysql-test/suite/galera/r/galera_bf_abort_at_after_statement.result +++ b/mysql-test/suite/galera/r/galera_bf_abort_at_after_statement.result @@ -4,6 +4,7 @@ connection node_1; CREATE TABLE t1 (id INT PRIMARY KEY, val INT); INSERT INTO t1 VALUES (1, 1); connection node_2; +SET DEBUG_SYNC = 'RESET'; START TRANSACTION; SET DEBUG_SYNC = 'wsrep_after_statement_enter SIGNAL blocked WAIT_FOR continue'; UPDATE t1 SET val=2 WHERE id=1; @@ -18,4 +19,5 @@ ERROR 40001: Deadlock found when trying to get lock; try restarting transaction COMMIT; SET DEBUG_SYNC = 'RESET'; connection node_1; +SET DEBUG_SYNC = 'RESET'; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_kill_applier.result b/mysql-test/suite/galera/r/galera_kill_applier.result index 25600744d73..78a91d2638f 100644 --- a/mysql-test/suite/galera/r/galera_kill_applier.result +++ b/mysql-test/suite/galera/r/galera_kill_applier.result @@ -1,20 +1,26 @@ connection node_2; connection node_1; connection node_2; +SELECT @@wsrep_slave_threads; +@@wsrep_slave_threads +1 SET GLOBAL wsrep_slave_threads=2; Got one of the listed errors Got one of the listed errors Got one of the listed errors Got one of the listed errors -SET GLOBAL wsrep_slave_threads=1; +SET GLOBAL wsrep_slave_threads=DEFAULT; connection node_1; create table t1(a int not null primary key) engine=innodb; insert into t1 values (1); insert into t1 values (2); connection node_2; -set global wsrep_sync_wait=15; +# Wait until one of the appliers has exited select count(*) from t1; count(*) 2 +SELECT @@wsrep_slave_threads; +@@wsrep_slave_threads +1 connection node_1; drop table t1; diff --git a/mysql-test/suite/galera/r/galera_unicode_pk.result b/mysql-test/suite/galera/r/galera_unicode_pk.result index bb36fd4f369..8ed1a3a077e 100644 --- a/mysql-test/suite/galera/r/galera_unicode_pk.result +++ b/mysql-test/suite/galera/r/galera_unicode_pk.result @@ -1,5 +1,6 @@ connection node_2; connection node_1; +connection node_1; CREATE TABLE t1 ( f1 VARCHAR(255) PRIMARY KEY ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/mysql-test/suite/galera/r/galera_update_limit.result b/mysql-test/suite/galera/r/galera_update_limit.result index 30c89a38dff..bd021136ac2 100644 --- a/mysql-test/suite/galera/r/galera_update_limit.result +++ b/mysql-test/suite/galera/r/galera_update_limit.result @@ -1,9 +1,9 @@ connection node_2; connection node_1; connection node_1; -CREATE TABLE ten (f1 INTEGER) Engine=InnoDB; +CREATE TABLE ten (f1 INTEGER not null primary key) Engine=InnoDB; INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; +CREATE TABLE t1 (f1 INTEGER NOT NULL PRIMARY KEY) Engine=InnoDB; INSERT INTO t1 SELECT f1 FROM ten ORDER BY RAND(); connection node_2; UPDATE IGNORE t1 SET f1 = FLOOR(1 + (RAND() * 10)) ORDER BY RAND() LIMIT 5; diff --git a/mysql-test/suite/galera/t/galera_as_slave_replay.cnf b/mysql-test/suite/galera/t/galera_as_slave_replay.cnf index b1f9d7e9cbd..c20c65f86d9 100644 --- a/mysql-test/suite/galera/t/galera_as_slave_replay.cnf +++ b/mysql-test/suite/galera/t/galera_as_slave_replay.cnf @@ -5,7 +5,9 @@ binlog-format=row [mysqld.1] wsrep_restart_slave=1 +wsrep-debug=1 [mysqld.2] wsrep_restart_slave=1 +wsrep-debug=1 diff --git a/mysql-test/suite/galera/t/galera_as_slave_replay.test b/mysql-test/suite/galera/t/galera_as_slave_replay.test index 2e8f45a047b..725d72c4144 100644 --- a/mysql-test/suite/galera/t/galera_as_slave_replay.test +++ b/mysql-test/suite/galera/t/galera_as_slave_replay.test @@ -131,70 +131,6 @@ set session wsrep_sync_wait=0; SELECT * FROM t1; SET DEBUG_SYNC = "RESET"; -#******************************************************************************** -# test phase 2 -#******************************************************************************** - ---echo # ---echo # test phase with real abort ---echo # - ---connection node_3 - -set binlog_format=ROW; - -insert into t1 values (4, 'd'); - -SET AUTOCOMMIT=ON; -START TRANSACTION; - -UPDATE t1 SET f2 = 'd' WHERE f1 = 3; - ---connection node_2a -# wait for the last insert to be replicated from master ---let $wait_condition = SELECT COUNT(*) = 4 FROM test.t1; ---source include/wait_condition.inc - -# Block the commit ---let $galera_sync_point = commit_monitor_enter_sync ---source include/galera_set_sync_point.inc - -# block applier -SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb"; - -# Inject a conflicting update from node 3 ---connection node_1 -UPDATE test.t1 SET f2 = 'e' WHERE f1 = 3; - -# send the update from master ---connection node_3 ---error 0 -COMMIT; - ---connection node_2a - -# release the applier -SET GLOBAL debug_dbug = ""; -SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; - - -# Unblock the async slave commit ---connection node_2a ---source include/galera_clear_sync_point.inc ---source include/galera_signal_sync_point.inc -SET DEBUG_SYNC = "RESET"; - ---connection node_2a -set session wsrep_sync_wait=0; ---let $wait_condition = SELECT COUNT(*) = 1 FROM test.t1 where f2 = 'e' ---source include/wait_condition.inc -SELECT * from test.t1; - ---connection node_1 ---let $wait_condition = SELECT COUNT(*) = 1 FROM test.t1 where f2 = 'e' ---source include/wait_condition.inc -SELECT * from test.t1; - --connection node_2a STOP SLAVE; RESET SLAVE; @@ -204,3 +140,7 @@ DROP TABLE t1; --connection node_3 DROP TABLE t1; RESET MASTER; + +--connection node_1 +--disconnect node_2a +--disconnect node_3 diff --git a/mysql-test/suite/galera/t/galera_bad_wsrep_new_cluster.cnf b/mysql-test/suite/galera/t/galera_bad_wsrep_new_cluster.cnf new file mode 100644 index 00000000000..62cf1854032 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_bad_wsrep_new_cluster.cnf @@ -0,0 +1,7 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +wsrep-debug=1 + +[mysqld.2] +wsrep-debug=1 diff --git a/mysql-test/suite/galera/t/galera_bf_abort_at_after_statement.cnf b/mysql-test/suite/galera/t/galera_bf_abort_at_after_statement.cnf new file mode 100644 index 00000000000..62cf1854032 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_bf_abort_at_after_statement.cnf @@ -0,0 +1,7 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +wsrep-debug=1 + +[mysqld.2] +wsrep-debug=1 diff --git a/mysql-test/suite/galera/t/galera_bf_abort_at_after_statement.test b/mysql-test/suite/galera/t/galera_bf_abort_at_after_statement.test index b1fe3e64cd8..738aedbda9e 100644 --- a/mysql-test/suite/galera/t/galera_bf_abort_at_after_statement.test +++ b/mysql-test/suite/galera/t/galera_bf_abort_at_after_statement.test @@ -8,10 +8,21 @@ --source include/have_debug_sync.inc --connection node_1 +# Mare sure both nodes are in the cluster +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + CREATE TABLE t1 (id INT PRIMARY KEY, val INT); INSERT INTO t1 VALUES (1, 1); --connection node_2 +SET DEBUG_SYNC = 'RESET'; +# Mare sure that DLL has replicated and insert has replicated +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1' +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM t1 +--source include/wait_condition.inc + START TRANSACTION; SET DEBUG_SYNC = 'wsrep_after_statement_enter SIGNAL blocked WAIT_FOR continue'; --send UPDATE t1 SET val=2 WHERE id=1 @@ -34,4 +45,5 @@ COMMIT; SET DEBUG_SYNC = 'RESET'; --connection node_1 +SET DEBUG_SYNC = 'RESET'; DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_kill_applier.cnf b/mysql-test/suite/galera/t/galera_kill_applier.cnf new file mode 100644 index 00000000000..62cf1854032 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_kill_applier.cnf @@ -0,0 +1,7 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +wsrep-debug=1 + +[mysqld.2] +wsrep-debug=1 diff --git a/mysql-test/suite/galera/t/galera_kill_applier.test b/mysql-test/suite/galera/t/galera_kill_applier.test index 4136bac5dc6..3a285822613 100644 --- a/mysql-test/suite/galera/t/galera_kill_applier.test +++ b/mysql-test/suite/galera/t/galera_kill_applier.test @@ -7,9 +7,10 @@ --source include/force_restart.inc --connection node_2 +SELECT @@wsrep_slave_threads; SET GLOBAL wsrep_slave_threads=2; ---let $wait_condition = SELECT COUNT(*) >= 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; +--let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; --let $wait_condition_on_error_output = SELECT COUNT(*), 2 as EXPECTED_VALUE FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; show processlist --source include/wait_condition_with_debug.inc @@ -31,7 +32,7 @@ SET GLOBAL wsrep_slave_threads=2; --eval KILL QUERY $aborter_thread --enable_query_log -SET GLOBAL wsrep_slave_threads=1; +SET GLOBAL wsrep_slave_threads=DEFAULT; --connection node_1 create table t1(a int not null primary key) engine=innodb; @@ -39,8 +40,13 @@ insert into t1 values (1); insert into t1 values (2); --connection node_2 -set global wsrep_sync_wait=15; +--echo # Wait until one of the appliers has exited +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count'; +--let $wait_condition_on_error_output = SELECT COUNT(*), 1 as EXPECTED_VALUE FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; show processlist +--source include/wait_condition_with_debug.inc + select count(*) from t1; +SELECT @@wsrep_slave_threads; --connection node_1 drop table t1; diff --git a/mysql-test/suite/galera/t/galera_sp_bf_abort.cnf b/mysql-test/suite/galera/t/galera_sp_bf_abort.cnf new file mode 100644 index 00000000000..62cf1854032 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sp_bf_abort.cnf @@ -0,0 +1,7 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +wsrep-debug=1 + +[mysqld.2] +wsrep-debug=1 diff --git a/mysql-test/suite/galera/t/galera_unicode_pk.cnf b/mysql-test/suite/galera/t/galera_unicode_pk.cnf new file mode 100644 index 00000000000..62cf1854032 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_unicode_pk.cnf @@ -0,0 +1,7 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +wsrep-debug=1 + +[mysqld.2] +wsrep-debug=1 diff --git a/mysql-test/suite/galera/t/galera_unicode_pk.test b/mysql-test/suite/galera/t/galera_unicode_pk.test index 0d571f5cfd7..2da9b1b9b8a 100644 --- a/mysql-test/suite/galera/t/galera_unicode_pk.test +++ b/mysql-test/suite/galera/t/galera_unicode_pk.test @@ -5,6 +5,11 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +--connection node_1 +# Mare sure both nodes are in the cluster +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + CREATE TABLE t1 ( f1 VARCHAR(255) PRIMARY KEY ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -12,6 +17,12 @@ CREATE TABLE t1 ( INSERT INTO t1 VALUES ('текст'); --connection node_2 +# Mare sure that DLL has replicated and insert has replicated +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1' +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM t1 +--source include/wait_condition.inc + SELECT f1 = 'текст' FROM t1; # diff --git a/mysql-test/suite/galera/t/galera_update_limit.cnf b/mysql-test/suite/galera/t/galera_update_limit.cnf new file mode 100644 index 00000000000..62cf1854032 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_update_limit.cnf @@ -0,0 +1,7 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +wsrep-debug=1 + +[mysqld.2] +wsrep-debug=1 diff --git a/mysql-test/suite/galera/t/galera_update_limit.test b/mysql-test/suite/galera/t/galera_update_limit.test index baacf2a60b2..e2823bf7124 100644 --- a/mysql-test/suite/galera/t/galera_update_limit.test +++ b/mysql-test/suite/galera/t/galera_update_limit.test @@ -4,17 +4,16 @@ # --source include/galera_cluster.inc ---source include/have_innodb.inc # # With a PK # --connection node_1 -CREATE TABLE ten (f1 INTEGER) Engine=InnoDB; +CREATE TABLE ten (f1 INTEGER not null primary key) Engine=InnoDB; INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; +CREATE TABLE t1 (f1 INTEGER NOT NULL PRIMARY KEY) Engine=InnoDB; INSERT INTO t1 SELECT f1 FROM ten ORDER BY RAND(); --connection node_2 -- cgit v1.2.1 From f9726ced257b8fdaa2e027464f45cd3d6b6f5728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 1 Dec 2021 13:43:43 +0200 Subject: MDEV-12353 fixup: Correct a comment Several EXTENDED type records have already been implemented. --- storage/innobase/include/mtr0types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/include/mtr0types.h b/storage/innobase/include/mtr0types.h index d1b6784ae86..4a47819e8c8 100644 --- a/storage/innobase/include/mtr0types.h +++ b/storage/innobase/include/mtr0types.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -209,7 +209,7 @@ enum mrec_type_t /** Zero-initialize a page. The current byte offset (for subsequent records) will be reset to FIL_PAGE_TYPE. */ INIT_PAGE= 0x10, - /** Insert a record into a page. FIXME: implement this! */ + /** Extended record; @see mrec_ext_t */ EXTENDED= 0x20, /** Write a string of bytes. Followed by the byte offset (unsigned, relative to the current byte offset, encoded in 1 to 3 bytes) and -- cgit v1.2.1 From 1b0fb2faa9019ce35b9aea56eaafa82a5b3d4c5b Mon Sep 17 00:00:00 2001 From: Christopher Odenbach Date: Thu, 22 Nov 2018 11:54:10 +0100 Subject: Fix logrotate problem with twice configured pid-file option Hi, if the pid-file option is configured more than once (e.g. multiple times in different files), my_print_defaults prints it twice, resulting in the logrotate postrotate script failing because of a syntax error. Debian fixed this already (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=830976#42). Perhaps you could implement this small change in the other branches as well? Thanks, Christopher --- debian/mariadb-server-10.4.mysql-server.logrotate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/mariadb-server-10.4.mysql-server.logrotate b/debian/mariadb-server-10.4.mysql-server.logrotate index 4111a276dc3..34ef6385e8e 100644 --- a/debian/mariadb-server-10.4.mysql-server.logrotate +++ b/debian/mariadb-server-10.4.mysql-server.logrotate @@ -11,7 +11,7 @@ sharedscripts postrotate test -x /usr/bin/mysqladmin || exit 0 - if [ -f `my_print_defaults --mysqld | grep -oP "pid-file=\K[^$]+"` ]; then + if [ -f `my_print_defaults --mysqld | grep -m 1 -oP "pid-file=\K.+$"` ]; then # If this fails, check debian.conf! mysqladmin --defaults-file=/etc/mysql/debian.cnf --local flush-error-log \ flush-engine-log flush-general-log flush-slow-log -- cgit v1.2.1 From 658a1e1fed81504c027f1d0d81abad5b9bb6c0d4 Mon Sep 17 00:00:00 2001 From: Christopher Odenbach Date: Wed, 3 Apr 2019 08:54:06 +0200 Subject: Use mysqladmin ping instead of pid files How 'bout know? --- debian/mariadb-server-10.4.mysql-server.logrotate | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/mariadb-server-10.4.mysql-server.logrotate b/debian/mariadb-server-10.4.mysql-server.logrotate index 34ef6385e8e..11e4480c427 100644 --- a/debian/mariadb-server-10.4.mysql-server.logrotate +++ b/debian/mariadb-server-10.4.mysql-server.logrotate @@ -11,8 +11,8 @@ sharedscripts postrotate test -x /usr/bin/mysqladmin || exit 0 - if [ -f `my_print_defaults --mysqld | grep -m 1 -oP "pid-file=\K.+$"` ]; then - # If this fails, check debian.conf! + # check if server is running + if mysqladmin ping > /dev/null 2>&1; then mysqladmin --defaults-file=/etc/mysql/debian.cnf --local flush-error-log \ flush-engine-log flush-general-log flush-slow-log fi -- cgit v1.2.1 From f458acc81e805d148e01f60fe5c2ded622df7c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 3 Dec 2021 09:56:30 +0200 Subject: MDEV-27160 Out of memory in main.long_unique A part of the test main.long_unique attempts to insert records with two 60,000,001-byte columns. Let us move that test into a separate file main.long_unique_big, declared as big test, so that it can be skipped in environments with limited memory. --- mysql-test/main/long_unique.result | 43 ---------------------------------- mysql-test/main/long_unique.test | 29 ++--------------------- mysql-test/main/long_unique_big.result | 38 ++++++++++++++++++++++++++++++ mysql-test/main/long_unique_big.test | 26 ++++++++++++++++++++ 4 files changed, 66 insertions(+), 70 deletions(-) create mode 100644 mysql-test/main/long_unique_big.result create mode 100644 mysql-test/main/long_unique_big.test diff --git a/mysql-test/main/long_unique.result b/mysql-test/main/long_unique.result index 23d25e2f124..755612c7915 100644 --- a/mysql-test/main/long_unique.result +++ b/mysql-test/main/long_unique.result @@ -3,7 +3,6 @@ #table containing single unique column #table containing keys like unique(a,b,c,d) etc #then table containing 2 blob unique etc -set @allowed_packet= @@max_allowed_packet; #table with single long blob column; create table t1(a blob unique ); insert into t1 values(1),(2),(3),(56),('sachin'),('maria'),(123456789034567891),(null),(null),(123456789034567890); @@ -1225,44 +1224,6 @@ DB_ROW_HASH_1 33 44 drop table t1,t2; -#very long blob entry; -SET @@GLOBAL.max_allowed_packet=67108864; -connect 'newcon', localhost, root,,; -connection newcon; -show variables like 'max_allowed_packet'; -Variable_name Value -max_allowed_packet 67108864 -create table t1(a longblob unique, b longblob , c longblob , unique(b,c)); -desc t1; -Field Type Null Key Default Extra -a longblob YES UNI NULL -b longblob YES MUL NULL -c longblob YES NULL -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` longblob DEFAULT NULL, - `b` longblob DEFAULT NULL, - `c` longblob DEFAULT NULL, - UNIQUE KEY `a` (`a`) USING HASH, - UNIQUE KEY `b` (`b`,`c`) USING HASH -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 a 1 a A NULL NULL NULL YES HASH -t1 0 b 1 b A NULL NULL NULL YES HASH -t1 0 b 2 c A NULL NULL NULL YES HASH -insert into t1 values(concat(repeat('sachin',10000000),'1'),concat(repeat('sachin',10000000),'1'), -concat(repeat('sachin',10000000),'1')); -insert into t1 values(concat(repeat('sachin',10000000),'2'),concat(repeat('sachin',10000000),'2'), -concat(repeat('sachin',10000000),'1')); -insert into t1 values(concat(repeat('sachin',10000000),'2'),concat(repeat('sachin',10000000),'2'), -concat(repeat('sachin',10000000),'4')); -ERROR 23000: Duplicate entry 'sachinsachinsachinsachinsachinsachinsachinsachinsachinsachins...' for key 'a' -insert into t1 values(concat(repeat('sachin',10000000),'3'),concat(repeat('sachin',10000000),'1'), -concat(repeat('sachin',10000000),'1')); -ERROR 23000: Duplicate entry 'sachinsachinsachinsachinsachinsachinsachinsachinsachinsachins...' for key 'b' -drop table t1; #long key unique with different key length create table t1(a blob, unique(a(3000))); desc t1; @@ -1307,9 +1268,6 @@ t1 0 a 2 b A NULL NULL NULL YES HASH t1 0 c 1 c A NULL 4500 NULL YES HASH t1 0 c 2 d A NULL NULL NULL YES HASH drop table t1; -disconnect newcon; -connection default; -SET @@GLOBAL.max_allowed_packet=4194304; #ext bug create table t1(a int primary key, b blob unique, c int, d blob , index(c)); show create table t1; @@ -1477,5 +1435,4 @@ id select_type table type possible_keys key key_len ref rows Extra SELECT t2.b FROM t1 JOIN t2 ON t1.d = t2.f WHERE t2.pk >= 20; b drop table t1,t2; -set @@GLOBAL.max_allowed_packet= @allowed_packet; # End of 10.4 tests diff --git a/mysql-test/main/long_unique.test b/mysql-test/main/long_unique.test index 7aaff303ae7..f1a08b3dc29 100644 --- a/mysql-test/main/long_unique.test +++ b/mysql-test/main/long_unique.test @@ -10,7 +10,7 @@ let datadir=`select @@datadir`; --echo #table containing single unique column --echo #table containing keys like unique(a,b,c,d) etc --echo #then table containing 2 blob unique etc -set @allowed_packet= @@max_allowed_packet; + --echo #table with single long blob column; create table t1(a blob unique ); insert into t1 values(1),(2),(3),(56),('sachin'),('maria'),(123456789034567891),(null),(null),(123456789034567890); @@ -396,28 +396,6 @@ select DB_ROW_HASH_1 from t1,t2 where t1.DB_ROW_HASH_1 = t2.DB_ROW_HASH_2; select DB_ROW_HASH_1 from t1 inner join t2 on t1.a = t2.DB_ROW_HASH_2; drop table t1,t2; ---echo #very long blob entry; -SET @@GLOBAL.max_allowed_packet=67108864; - -connect ('newcon', localhost, root,,); ---connection newcon -show variables like 'max_allowed_packet'; -create table t1(a longblob unique, b longblob , c longblob , unique(b,c)); -desc t1; -show create table t1; -show keys from t1; -insert into t1 values(concat(repeat('sachin',10000000),'1'),concat(repeat('sachin',10000000),'1'), -concat(repeat('sachin',10000000),'1')); -insert into t1 values(concat(repeat('sachin',10000000),'2'),concat(repeat('sachin',10000000),'2'), -concat(repeat('sachin',10000000),'1')); ---error ER_DUP_ENTRY -insert into t1 values(concat(repeat('sachin',10000000),'2'),concat(repeat('sachin',10000000),'2'), -concat(repeat('sachin',10000000),'4')); ---error ER_DUP_ENTRY -insert into t1 values(concat(repeat('sachin',10000000),'3'),concat(repeat('sachin',10000000),'1'), -concat(repeat('sachin',10000000),'1')); -drop table t1; - --echo #long key unique with different key length create table t1(a blob, unique(a(3000))); desc t1; @@ -435,9 +413,7 @@ desc t1; show create table t1; show keys from t1; drop table t1; -disconnect newcon; ---connection default -SET @@GLOBAL.max_allowed_packet=4194304; + --echo #ext bug create table t1(a int primary key, b blob unique, c int, d blob , index(c)); show create table t1; @@ -556,5 +532,4 @@ SELECT t2.b FROM t1 JOIN t2 ON t1.d = t2.f WHERE t2.pk >= 20; SELECT t2.b FROM t1 JOIN t2 ON t1.d = t2.f WHERE t2.pk >= 20; drop table t1,t2; -set @@GLOBAL.max_allowed_packet= @allowed_packet; --echo # End of 10.4 tests diff --git a/mysql-test/main/long_unique_big.result b/mysql-test/main/long_unique_big.result new file mode 100644 index 00000000000..2ec84e510cb --- /dev/null +++ b/mysql-test/main/long_unique_big.result @@ -0,0 +1,38 @@ +set @allowed_packet= @@max_allowed_packet; +SET GLOBAL max_allowed_packet=67108864; +connect con1, localhost, root,,; +create table t1(a longblob unique, b longblob , c longblob , unique(b,c)); +desc t1; +Field Type Null Key Default Extra +a longblob YES UNI NULL +b longblob YES MUL NULL +c longblob YES NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` longblob DEFAULT NULL, + `b` longblob DEFAULT NULL, + `c` longblob DEFAULT NULL, + UNIQUE KEY `a` (`a`) USING HASH, + UNIQUE KEY `b` (`b`,`c`) USING HASH +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +show keys from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +t1 0 a 1 a A NULL NULL NULL YES HASH +t1 0 b 1 b A NULL NULL NULL YES HASH +t1 0 b 2 c A NULL NULL NULL YES HASH +insert into t1 values(concat(repeat('sachin',10000000),'1'),concat(repeat('sachin',10000000),'1'), +concat(repeat('sachin',10000000),'1')); +insert into t1 values(concat(repeat('sachin',10000000),'2'),concat(repeat('sachin',10000000),'2'), +concat(repeat('sachin',10000000),'1')); +insert into t1 values(concat(repeat('sachin',10000000),'2'),concat(repeat('sachin',10000000),'2'), +concat(repeat('sachin',10000000),'4')); +ERROR 23000: Duplicate entry 'sachinsachinsachinsachinsachinsachinsachinsachinsachinsachins...' for key 'a' +insert into t1 values(concat(repeat('sachin',10000000),'3'),concat(repeat('sachin',10000000),'1'), +concat(repeat('sachin',10000000),'1')); +ERROR 23000: Duplicate entry 'sachinsachinsachinsachinsachinsachinsachinsachinsachinsachins...' for key 'b' +drop table t1; +disconnect con1; +connection default; +set @@GLOBAL.max_allowed_packet= @allowed_packet; +# End of 10.4 tests diff --git a/mysql-test/main/long_unique_big.test b/mysql-test/main/long_unique_big.test new file mode 100644 index 00000000000..c87b6e0b9eb --- /dev/null +++ b/mysql-test/main/long_unique_big.test @@ -0,0 +1,26 @@ +# This test may run out of memory in some environments. +--source include/big_test.inc + +set @allowed_packet= @@max_allowed_packet; +SET GLOBAL max_allowed_packet=67108864; + +connect (con1, localhost, root,,); +create table t1(a longblob unique, b longblob , c longblob , unique(b,c)); +desc t1; +show create table t1; +show keys from t1; +insert into t1 values(concat(repeat('sachin',10000000),'1'),concat(repeat('sachin',10000000),'1'), +concat(repeat('sachin',10000000),'1')); +insert into t1 values(concat(repeat('sachin',10000000),'2'),concat(repeat('sachin',10000000),'2'), +concat(repeat('sachin',10000000),'1')); +--error ER_DUP_ENTRY +insert into t1 values(concat(repeat('sachin',10000000),'2'),concat(repeat('sachin',10000000),'2'), +concat(repeat('sachin',10000000),'4')); +--error ER_DUP_ENTRY +insert into t1 values(concat(repeat('sachin',10000000),'3'),concat(repeat('sachin',10000000),'1'), +concat(repeat('sachin',10000000),'1')); +drop table t1; +disconnect con1; +connection default; +set @@GLOBAL.max_allowed_packet= @allowed_packet; +--echo # End of 10.4 tests -- cgit v1.2.1 From 5d7da02793b514644574b35eff8aa480d98b6a5d Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Mon, 29 Nov 2021 18:55:16 +0600 Subject: MDEV-27139 32-bit systems fail to use big innodb-log-file-size log_write_buf(): do not cast to size_t which prevents to write to files which a bigger that 4G and remove useless assertion --- storage/innobase/log/log0log.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index f677aedc87c..906979ffe20 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -610,9 +610,7 @@ loop: log_block_store_checksum(buf + i * OS_FILE_LOG_BLOCK_SIZE); } - ut_a((next_offset >> srv_page_size_shift) <= ULINT_MAX); - - log_sys.log.write(static_cast(next_offset), {buf, write_len}); + log_sys.log.write(next_offset, {buf, write_len}); if (write_len < len) { start_lsn += write_len; -- cgit v1.2.1 From fa1325512b002f4f517dacd851fea998a7af498c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 3 Dec 2021 17:01:48 +0200 Subject: Correct some comments In commit aae3f921adec9b9d1bff093c9a75a94e44f5c8d4 recv_apply_hashed_log_recs() was replaced by recv_sys_t::apply(). --- storage/innobase/include/log0recv.h | 6 +++--- storage/innobase/srv/srv0start.cc | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h index f822a874565..fcc7e989885 100644 --- a/storage/innobase/include/log0recv.h +++ b/storage/innobase/include/log0recv.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -214,8 +214,8 @@ struct recv_sys_t /** whether recv_recover_page(), invoked from buf_page_read_complete(), should apply log records*/ bool apply_log_recs; - /** whether recv_apply_hashed_log_recs() is running */ - bool apply_batch_on; + /** whether apply() is running */ + bool apply_batch_on; byte* buf; /*!< buffer for parsing log records */ ulint len; /*!< amount of data in buf */ lsn_t parse_start_lsn; diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index aa6e7ce11f9..f545b482220 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -1474,8 +1474,7 @@ file_checked: } /* fall through */ case SRV_OPERATION_RESTORE: - /* This must precede - recv_apply_hashed_log_recs(true). */ + /* This must precede recv_sys.apply(true). */ srv_undo_tablespaces_active = trx_rseg_get_n_undo_tablespaces(); err = srv_validate_undo_tablespaces(); -- cgit v1.2.1 From 6deaff58a9d5208f3c2a3e57fd17ecac17fe34ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 4 Dec 2021 12:55:26 +0200 Subject: MDEV-27058 fixup: GCC 11 -march=i686 -Warray-bounds page_zip_des_t::clear(): Avoid a bogus GCC warning with some pointer arithmetics. Yes, storing the unrelated member "fix" in this object is ugly, but it avoids memory alignment overhead on 64-bit architectures. --- storage/innobase/include/page0types.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/storage/innobase/include/page0types.h b/storage/innobase/include/page0types.h index d18cea66b30..885d2290f7c 100644 --- a/storage/innobase/include/page0types.h +++ b/storage/innobase/include/page0types.h @@ -113,9 +113,10 @@ struct page_zip_des_t #endif /* UNIV_DEBUG */ void clear() { - memset((void*) this, 0, sizeof(data) + sizeof(uint32_t)); - ut_d(m_start = 0); - ut_d(m_external = false); + /* Clear everything except the member "fix". */ + memset((void*) this, 0, + reinterpret_cast(&fix) + - reinterpret_cast(this)); } private: -- cgit v1.2.1