From 214023aa0e6ec00dcac386167a2b2cf9394b6c7e Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 18 Jan 2019 13:45:06 +1100 Subject: systemd: mariadb@bootstrap doesn't bootstrap, galera_new_cluster does Closes #1106 --- support-files/mariadb@.service.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-files/mariadb@.service.in b/support-files/mariadb@.service.in index 4838620b8cd..8afae3bd09b 100644 --- a/support-files/mariadb@.service.in +++ b/support-files/mariadb@.service.in @@ -1,5 +1,5 @@ # Multi instance version of mariadb. For if you run multiple versions at once. -# Also used for mariadb@bootstrap to bootstrap Galera. +# Also used for mariadb@bootstrap to tell you to use galera_new_cluster. # # create config file @sysconf2dir@/my{instancename}.cnf # -- cgit v1.2.1 From 290972563673a7de32e10bb0e4bdb37295be1371 Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Mon, 18 Nov 2019 11:50:58 +0530 Subject: MDEV-21044: Wrong result when using a smaller size for sort buffer Make sure that the sort buffers can store atleast one sort key. This is needed to make sure that all merge buffers are read else with no sort keys some merge buffers are skipped because the code makes a conclusion there is no data to be read. --- mysql-test/r/order_by.result | 30 ++++++++++++++++++++++++++++++ mysql-test/t/order_by.test | 16 ++++++++++++++++ sql/filesort.cc | 1 + 3 files changed, 47 insertions(+) diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index 4cd9aebdf49..380687554d7 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -3207,3 +3207,33 @@ pk 2 3 DROP TABLE t1; +# +# MDEV-21044: Wrong result when using a smaller size for sort buffer +# +create table t1(a varchar(765),b int); +insert into t1 values ("a",1),("b",2),("c",3),("e",4); +insert into t1 values ("d",5),("f",6),("g",7),("h",8); +insert into t1 values ("k",11),("l",12),("i",9),("j",10); +insert into t1 values ("m",13),("n",14),("o",15),("p",16); +set @save_sort_buffer_size= @@sort_buffer_size; +set sort_buffer_size=1024; +select * from t1 order by b; +a b +a 1 +b 2 +c 3 +e 4 +d 5 +f 6 +g 7 +h 8 +i 9 +j 10 +k 11 +l 12 +m 13 +n 14 +o 15 +p 16 +set @@sort_buffer_size= @save_sort_buffer_size; +drop table t1; diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 1ca258d1d48..999c7314139 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -2141,3 +2141,19 @@ INSERT INTO t1 VALUES (1),(2),(3); SELECT DISTINCT pk FROM t1 GROUP BY 'foo'; SELECT DISTINCT pk FROM t1; DROP TABLE t1; + +--echo # +--echo # MDEV-21044: Wrong result when using a smaller size for sort buffer +--echo # + +create table t1(a varchar(765),b int); +insert into t1 values ("a",1),("b",2),("c",3),("e",4); +insert into t1 values ("d",5),("f",6),("g",7),("h",8); +insert into t1 values ("k",11),("l",12),("i",9),("j",10); +insert into t1 values ("m",13),("n",14),("o",15),("p",16); +set @save_sort_buffer_size= @@sort_buffer_size; +set sort_buffer_size=1024; +select * from t1 order by b; +set @@sort_buffer_size= @save_sort_buffer_size; +drop table t1; + diff --git a/sql/filesort.cc b/sql/filesort.cc index 4f195f68059..bb3e73343ad 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -343,6 +343,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, param.max_keys_per_buffer=((param.max_keys_per_buffer * (param.rec_length + sizeof(char*))) / param.rec_length - 1); + set_if_bigger(param.max_keys_per_buffer, 1); maxbuffer--; // Offset from 0 if (merge_many_buff(¶m, (uchar*) table_sort.get_sort_keys(), -- cgit v1.2.1 From 5c68343db713b9a2881809f6e21107d73a7d7b46 Mon Sep 17 00:00:00 2001 From: seppo Date: Mon, 18 Nov 2019 15:18:00 +0200 Subject: MDEV-18497 CTAS async replication from mariadb master crashes galera nodes (#1410) This PR contains a mtr test for reproducing a failure with replicating create table as select statement (CTAS) through asynchronous mariadb replication to mariadb galera cluster. The problem happens when CTAS replication contains both create table statement followed by row events for populating the table. In such situation, the galera node operating as mariadb replication slave, will first replicate only the create table part into the cluster, and then perform another replication containing both the create table and row events. This will lead all other nodes to fail for duplicate table create attempt, and crash due to this failure. PR contains also a fix, which identifies the situation when CTAS has been replicated, and makes further scan in async replication stream to see if there are following row events. The slave node will replicate either single TOI in case the CTAS table is empty, or if CTAS table contains rows, then single bundled write set with create table and row events is replicated to galera cluster. This fix should keep master server's GTID's for CTAS replication in sync with GTID's in galera cluster. --- .../suite/galera/r/galera_as_slave_ctas.result | 14 ++++ mysql-test/suite/galera/t/galera_as_slave_ctas.cnf | 5 ++ .../suite/galera/t/galera_as_slave_ctas.test | 75 ++++++++++++++++++++++ sql/log_event.h | 3 + sql/slave.cc | 26 ++++++++ sql/wsrep_mysqld.cc | 34 +++++++++- 6 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/galera/r/galera_as_slave_ctas.result create mode 100644 mysql-test/suite/galera/t/galera_as_slave_ctas.cnf create mode 100644 mysql-test/suite/galera/t/galera_as_slave_ctas.test diff --git a/mysql-test/suite/galera/r/galera_as_slave_ctas.result b/mysql-test/suite/galera/r/galera_as_slave_ctas.result new file mode 100644 index 00000000000..79114824008 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_as_slave_ctas.result @@ -0,0 +1,14 @@ +START SLAVE; +SHOW VARIABLES LIKE 'binlog_format'; +Variable_name Value +binlog_format ROW +CREATE TABLE source (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE target AS SELECT * FROM source; +DROP TABLE target; +INSERT INTO source VALUES(1); +CREATE TABLE target AS SELECT * FROM source; +DROP TABLE source; +DROP TABLE target; +STOP SLAVE; +RESET SLAVE ALL; +RESET MASTER; diff --git a/mysql-test/suite/galera/t/galera_as_slave_ctas.cnf b/mysql-test/suite/galera/t/galera_as_slave_ctas.cnf new file mode 100644 index 00000000000..eab2a6de90d --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave_ctas.cnf @@ -0,0 +1,5 @@ +!include ../galera_2nodes_as_slave.cnf + +# make sure master server uses ROW format for replication +[mysqld] +binlog-format=row diff --git a/mysql-test/suite/galera/t/galera_as_slave_ctas.test b/mysql-test/suite/galera/t/galera_as_slave_ctas.test new file mode 100644 index 00000000000..7336449a3d0 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave_ctas.test @@ -0,0 +1,75 @@ +# +# Test Galera as a slave to a MySQL master +# +# The galera/galera_2node_slave.cnf describes the setup of the nodes +# also, for this test, master server must have binlog_format=ROW +# + +--source include/have_innodb.inc + +# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--source include/galera_cluster.inc + +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 + +--connection node_2 +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1; +--enable_query_log +START SLAVE; + + +# make sure master server has binlog_format=ROW +--connection node_1 +SHOW VARIABLES LIKE 'binlog_format'; + +# +# test phase one, issue CTAS with empty source table +# +--connection node_1 +CREATE TABLE source (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +CREATE TABLE target AS SELECT * FROM source; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'target'; +--source include/wait_condition.inc + +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'target'; +--source include/wait_condition.inc + +# +# test phase two, issue CTAS with populated source table +# +--connection node_1 +DROP TABLE target; +INSERT INTO source VALUES(1); + +CREATE TABLE target AS SELECT * FROM source; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM target; +--source include/wait_condition.inc + +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 1 FROM target; +--source include/wait_condition.inc + +--connection node_1 +DROP TABLE source; +DROP TABLE target; + +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'target'; +--source include/wait_condition.inc + + +--connection node_2 +STOP SLAVE; +RESET SLAVE ALL; + +--connection node_1 +RESET MASTER; +--sleep 20 diff --git a/sql/log_event.h b/sql/log_event.h index 9c555c54005..2c8dc3d7353 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -4967,6 +4967,9 @@ bool event_that_should_be_ignored(const char *buf); bool event_checksum_test(uchar *buf, ulong event_len, enum_binlog_checksum_alg alg); enum enum_binlog_checksum_alg get_checksum_alg(const char* buf, ulong len); extern TYPELIB binlog_checksum_typelib; +#ifdef WITH_WSREP +enum Log_event_type wsrep_peak_event(rpl_group_info *rgi, ulonglong* event_size); +#endif /* WITH_WSREP */ /** @} (end of group Replication) diff --git a/sql/slave.cc b/sql/slave.cc index 0ebed343a3d..bf8b8a43b15 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -7220,7 +7220,33 @@ err: sql_print_error("Error reading relay log event: %s", errmsg); DBUG_RETURN(0); } +#ifdef WITH_WSREP +enum Log_event_type wsrep_peak_event(rpl_group_info *rgi, ulonglong* event_size) +{ + mysql_mutex_lock(&rgi->rli->data_lock); + + unsigned long long event_pos= rgi->event_relay_log_pos; + unsigned long long future_pos= rgi->future_event_relay_log_pos; + + /* scan the log to read next event */ + my_b_seek(rgi->rli->cur_log, future_pos); + rgi->rli->event_relay_log_pos= future_pos; + rgi->event_relay_log_pos= future_pos; + + Log_event* ev = next_event(rgi, event_size); + enum Log_event_type ev_type= (ev) ? ev->get_type_code() : UNKNOWN_EVENT; + delete ev; + + /* scan the log back and re-set the positions to original values */ + rgi->rli->event_relay_log_pos= event_pos; + rgi->event_relay_log_pos= event_pos; + my_b_seek(rgi->rli->cur_log, future_pos); + + mysql_mutex_unlock(&rgi->rli->data_lock); + return ev_type; +} +#endif /* WITH_WSREP */ /* Rotate a relay log (this is used only by FLUSH LOGS; the automatic rotation because of size is simpler because when we do it we already have all relevant diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 0a519be073c..0627127c6e0 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -37,7 +37,6 @@ #include #include #include "log_event.h" -#include #include "sql_plugin.h" /* wsrep_plugins_pre_init() */ wsrep_t *wsrep = NULL; @@ -1502,6 +1501,39 @@ static bool wsrep_can_run_in_toi(THD *thd, const char *db, const char *table, { return false; } + /* + If mariadb master has replicated a CTAS, we should not replicate the create table + part separately as TOI, but to replicate both create table and following inserts + as one write set. + Howver, if CTAS creates empty table, we should replicate the create table alone + as TOI. We have to do relay log event lookup to see if row events follow the + create table event. + */ + if (thd->slave_thread && !(thd->rgi_slave->gtid_ev_flags2 & Gtid_log_event::FL_STANDALONE)) + { + /* this is CTAS, either empty or populated table */ + ulonglong event_size = 0; + enum Log_event_type ev_type= wsrep_peak_event(thd->rgi_slave, &event_size); + switch (ev_type) + { + case QUERY_EVENT: + /* CTAS with empty table, we replicate create table as TOI */ + break; + + case TABLE_MAP_EVENT: + WSREP_DEBUG("replicating CTAS of empty table as TOI"); + // fall through + case WRITE_ROWS_EVENT: + /* CTAS with populated table, we replicate later at commit time */ + WSREP_DEBUG("skipping create table of CTAS replication"); + return false; + + default: + WSREP_WARN("unexpected async replication event: %d", ev_type); + } + return true; + } + /* no next async replication event */ return true; case SQLCOM_CREATE_VIEW: -- cgit v1.2.1 From c6b097ab3702fe993ee81899fefa9779b8b969e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 18 Nov 2019 15:22:01 +0200 Subject: Remove excessive sleep from test. --- mysql-test/suite/galera/t/galera_as_slave_ctas.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/t/galera_as_slave_ctas.test b/mysql-test/suite/galera/t/galera_as_slave_ctas.test index 7336449a3d0..1a5e023b981 100644 --- a/mysql-test/suite/galera/t/galera_as_slave_ctas.test +++ b/mysql-test/suite/galera/t/galera_as_slave_ctas.test @@ -72,4 +72,4 @@ RESET SLAVE ALL; --connection node_1 RESET MASTER; ---sleep 20 + -- cgit v1.2.1 From 8fbfcce911d43091f34e1412269db785a0273641 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Tue, 19 Nov 2019 17:09:43 +0700 Subject: cleanup: remove always true condition to fix clang warning --- storage/connect/inihandl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/connect/inihandl.cpp b/storage/connect/inihandl.cpp index 8e79aeac7ef..dacab3c485c 100644 --- a/storage/connect/inihandl.cpp +++ b/storage/connect/inihandl.cpp @@ -194,7 +194,7 @@ static void PROFILE_Save( FILE *file, PROFILESECTION *section ) } for (key = section->key; key; key = key->next) - if (key->name && key->name[0]) { + if (key->name[0]) { fprintf(file, "%s", SVP(key->name)); if (key->value) -- cgit v1.2.1 From a51f3b09bb99f2927ce107727316caac2c426eb1 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Thu, 21 Nov 2019 00:32:27 +0700 Subject: cleanup DBUG DbugParse(): removed mutex lock/unlock which should protect file writes only. And no file writes happen in this function. DbugFlush(): move mutex_unlock out of this method because fflush() doesn't need any locking. Slow stuff like mutex lock/unlock and accessing errno (TLS) is moved to a more narrow scope. --- dbug/dbug.c | 67 ++++++++++++++++++++++++++----------------------------------- 1 file changed, 28 insertions(+), 39 deletions(-) diff --git a/dbug/dbug.c b/dbug/dbug.c index 54eebfe55a5..78605983ccb 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -322,6 +322,17 @@ static void DbugVfprintf(FILE *stream, const char* format, va_list args); #include static pthread_mutex_t THR_LOCK_dbug; +static void LockMutex(CODE_STATE *cs) +{ + if (!cs->locked) + pthread_mutex_lock(&THR_LOCK_dbug); +} +static void UnlockMutex(CODE_STATE *cs) +{ + if (!cs->locked) + pthread_mutex_unlock(&THR_LOCK_dbug); +} + static CODE_STATE *code_state(void) { CODE_STATE *cs, **cs_ptr; @@ -449,16 +460,9 @@ static int DbugParse(CODE_STATE *cs, const char *control) const char *end; int rel, f_used=0; struct settings *stack; - int org_cs_locked; stack= cs->stack; - if (!(org_cs_locked= cs->locked)) - { - cs->locked= 1; - pthread_mutex_lock(&THR_LOCK_dbug); - } - if (control[0] == '-' && control[1] == '#') control+=2; @@ -661,11 +665,6 @@ static int DbugParse(CODE_STATE *cs, const char *control) control=end+1; end= DbugStrTok(control); } - if (!org_cs_locked) - { - pthread_mutex_unlock(&THR_LOCK_dbug); - cs->locked= 0; - } return !rel || f_used; } @@ -1093,7 +1092,6 @@ int _db_explain_init_(char *buf, size_t len) void _db_enter_(const char *_func_, const char *_file_, uint _line_, struct _db_stack_frame_ *_stack_frame_) { - int save_errno; CODE_STATE *cs; if (!((cs=code_state()))) { @@ -1101,7 +1099,6 @@ void _db_enter_(const char *_func_, const char *_file_, _stack_frame_->prev= 0; return; } - save_errno= errno; _stack_frame_->line= -1; _stack_frame_->func= cs->func; @@ -1122,12 +1119,14 @@ void _db_enter_(const char *_func_, const char *_file_, cs->stack->flags &= ~SANITY_CHECK_ON; if (TRACING) { - if (!cs->locked) - pthread_mutex_lock(&THR_LOCK_dbug); + int save_errno= errno; + LockMutex(cs); DoPrefix(cs, _line_); Indent(cs, cs->level); (void) fprintf(cs->stack->out_file->file, ">%s\n", cs->func); - DbugFlush(cs); /* This does a unlock */ + UnlockMutex(cs); + DbugFlush(cs); + errno=save_errno; } break; case DISABLE_TRACE: @@ -1136,7 +1135,6 @@ void _db_enter_(const char *_func_, const char *_file_, case DONT_TRACE: break; } - errno=save_errno; } /* @@ -1161,7 +1159,6 @@ void _db_enter_(const char *_func_, const char *_file_, void _db_return_(struct _db_stack_frame_ *_stack_frame_) { - int save_errno=errno; uint _slevel_= _stack_frame_->level & ~TRACE_ON; CODE_STATE *cs; get_code_state_or_return; @@ -1182,12 +1179,14 @@ void _db_return_(struct _db_stack_frame_ *_stack_frame_) cs->stack->flags &= ~SANITY_CHECK_ON; if (TRACING) { - if (!cs->locked) - pthread_mutex_lock(&THR_LOCK_dbug); + int save_errno=errno; + LockMutex(cs); DoPrefix(cs, _stack_frame_->line); Indent(cs, cs->level); (void) fprintf(cs->stack->out_file->file, "<%s\n", cs->func); + UnlockMutex(cs); DbugFlush(cs); + errno=save_errno; } } /* @@ -1199,7 +1198,6 @@ void _db_return_(struct _db_stack_frame_ *_stack_frame_) cs->file= _stack_frame_->file; if (cs->framep != NULL) cs->framep= cs->framep->prev; - errno=save_errno; } @@ -1264,27 +1262,24 @@ void _db_doprnt_(const char *format,...) CODE_STATE *cs; get_code_state_or_return; - va_start(args,format); - if (!cs->locked) - pthread_mutex_lock(&THR_LOCK_dbug); if (_db_keyword_(cs, cs->u_keyword, 0)) { int save_errno=errno; + LockMutex(cs); DoPrefix(cs, cs->u_line); if (TRACING) Indent(cs, cs->level + 1); else (void) fprintf(cs->stack->out_file->file, "%s: ", cs->func); (void) fprintf(cs->stack->out_file->file, "%s: ", cs->u_keyword); + va_start(args,format); DbugVfprintf(cs->stack->out_file->file, format, args); + UnlockMutex(cs); + va_end(args); DbugFlush(cs); errno=save_errno; } - else if (!cs->locked) - pthread_mutex_unlock(&THR_LOCK_dbug); - - va_end(args); } /* @@ -1325,10 +1320,9 @@ void _db_dump_(uint _line_, const char *keyword, CODE_STATE *cs; get_code_state_or_return; - if (!cs->locked) - pthread_mutex_lock(&THR_LOCK_dbug); if (_db_keyword_(cs, keyword, 0)) { + LockMutex(cs); DoPrefix(cs, _line_); if (TRACING) { @@ -1356,10 +1350,9 @@ void _db_dump_(uint _line_, const char *keyword, fputc(' ',cs->stack->out_file->file); } (void) fputc('\n',cs->stack->out_file->file); + UnlockMutex(cs); DbugFlush(cs); } - else if (!cs->locked) - pthread_mutex_unlock(&THR_LOCK_dbug); } @@ -1938,16 +1931,16 @@ static void DBUGCloseFile(CODE_STATE *cs, sFILE *new_value) sFILE *fp; if (!cs || !cs->stack || !cs->stack->out_file) return; - if (!cs->locked) - pthread_mutex_lock(&THR_LOCK_dbug); fp= cs->stack->out_file; if (--fp->used == 0) { if (fclose(fp->file) == EOF) { + LockMutex(cs); (void) fprintf(stderr, ERR_CLOSE, cs->process); perror(""); + UnlockMutex(cs); } else { @@ -1955,8 +1948,6 @@ static void DBUGCloseFile(CODE_STATE *cs, sFILE *new_value) } } cs->stack->out_file= new_value; - if (!cs->locked) - pthread_mutex_unlock(&THR_LOCK_dbug); } @@ -2128,8 +2119,6 @@ static void DbugFlush(CODE_STATE *cs) if (cs->stack->delay) (void) Delay(cs->stack->delay); } - if (!cs->locked) - pthread_mutex_unlock(&THR_LOCK_dbug); } /* DbugFlush */ -- cgit v1.2.1 From d8ace23d260033fc6588599e0a03e2832d20dae9 Mon Sep 17 00:00:00 2001 From: Hashir Sarwar Date: Wed, 23 Oct 2019 17:40:24 +0500 Subject: Fixed some typos in mysql.cc Closes #1403 --- client/mysql.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 50d45696a5c..c872968b78d 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -3177,7 +3177,7 @@ static int com_go(String *buffer,char *line __attribute__((unused))) { char buff[200]; /* about 110 chars used so far */ - char time_buff[52+3+1]; /* time max + space&parens + NUL */ + char time_buff[52+3+1]; /* time max + space & parens + NUL */ MYSQL_RES *result; ulong timer, warnings= 0; uint error= 0; @@ -3196,7 +3196,7 @@ com_go(String *buffer,char *line __attribute__((unused))) if (buffer->is_empty()) { - if (status.batch) // Ignore empty quries + if (status.batch) // Ignore empty queries. return 0; return put_info("No query specified\n",INFO_ERROR); @@ -3261,7 +3261,7 @@ com_go(String *buffer,char *line __attribute__((unused))) else time_buff[0]= '\0'; - /* Every branch must truncate buff . */ + /* Every branch must truncate buff. */ if (result) { if (!mysql_num_rows(result) && ! quick && !column_types_flag) -- cgit v1.2.1 From 38839854b7c097b33f34b2228c4240fe837fda79 Mon Sep 17 00:00:00 2001 From: seppo Date: Tue, 26 Nov 2019 08:49:50 +0200 Subject: MDEV-19572 async slave node fails to apply MyISAM only writes (#1418) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The problem happens when MariaDB master replicates writes for only non InnoDB tables (e.g. writes to MyISAM table(s)). Async slave node, in Galera cluster, can apply these writes successfully, but it will, in the end, write gtid position in mysql.gtid_slave_pos table. mysql.gtid_slave_pos table is InnoDB engine, and this write makes innodb handlerton part of the replicated "transaction". Note that wsrep patch identifies that write to gtid_slave_pos should not be replicated and skips appending wsrep keys for these writes. However, as InnoDB was present in the transaction, and there are replication events (for MyISAM table) in transaction cache, but there are no appended keys, wsrep raises an error, and this makes the söave thread to stop. The fix is simply to not treat it as an error if async slave tries to replicate a write set with binlog events, but no keys. We just skip wsrep replication and return successfully. This commit contains also a mtr test which forces mysql.gtid_slave_pos table isto be of InnoDB engine, and executes MyISAM only write through asyn replication. There is additional fix for declaring IO and background slave threads as non wsrep. These threads should not write anything for wsrep replication, and this is just a safeguard to make sure nothing leaks into cluster from these slave threads. --- .../galera/r/galera_as_slave_gtid_myisam.result | 21 +++++++ .../suite/galera/t/galera_as_slave_gtid_myisam.cnf | 6 ++ .../galera/t/galera_as_slave_gtid_myisam.test | 65 ++++++++++++++++++++++ sql/slave.cc | 7 ++- sql/wsrep_hton.cc | 19 ++++++- 5 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result create mode 100644 mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf create mode 100644 mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test diff --git a/mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result b/mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result new file mode 100644 index 00000000000..d9a87571655 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result @@ -0,0 +1,21 @@ +ALTER TABLE mysql.gtid_slave_pos engine = InnoDB; +START SLAVE; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=MyISAM; +INSERT INTO t1 VALUES(1); +SELECT LENGTH(@@global.gtid_binlog_state) > 1; +LENGTH(@@global.gtid_binlog_state) > 1 +1 +gtid_binlog_state_equal +0 +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +gtid_binlog_state_equal +0 +#cleanup +DROP TABLE t1; +reset master; +STOP SLAVE; +RESET SLAVE ALL; +reset master; +reset master; diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf b/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf new file mode 100644 index 00000000000..01d2eb12630 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf @@ -0,0 +1,6 @@ +!include ../galera_2nodes_as_slave.cnf + +[mysqld] +log-bin=mysqld-bin +log-slave-updates +binlog-format=ROW diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test b/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test new file mode 100644 index 00000000000..faa9ddfd5c8 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test @@ -0,0 +1,65 @@ +# +# Test Galera as a slave to a MariaDB master using GTIDs +# +# suite/galera/galera_2nodes_as_slave.cnf describes the setup of the nodes +# suite/galera/t/galera_as_slave_gtid.cnf has the GTID options +# +# This test will replicate writes to MyISAM table and check that slave node is able +# to apply them. +# mysql.gtid_slave_pos table should be defined as innodb engine, original problem +# by writes to mysql.gtid_slave_pos, whereas the replicated transaction contained +# no innodb writes +# + +--source include/have_innodb.inc + +# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--source include/galera_cluster.inc + +--connection node_2 +# make sure gtid_slave_pos is of innodb engine, mtr does not currently provide that +ALTER TABLE mysql.gtid_slave_pos engine = InnoDB; + +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1; +--enable_query_log +START SLAVE; + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=MyISAM; +INSERT INTO t1 VALUES(1); + +SELECT LENGTH(@@global.gtid_binlog_state) > 1; +--let $gtid_binlog_state_node1 = `SELECT @@global.gtid_binlog_state;` + +--connection node_2 +--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 + +--disable_query_log +--eval SELECT '$gtid_binlog_state_node1' = @@global.gtid_binlog_state AS gtid_binlog_state_equal; +--enable_query_log + +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 +SELECT COUNT(*) = 0 FROM t1; + +--disable_query_log +--eval SELECT '$gtid_binlog_state_node1' = @@global.gtid_binlog_state AS gtid_binlog_state_equal; +--enable_query_log + +--echo #cleanup +--connection node_1 +DROP TABLE t1; +reset master; + +--connection node_2 +STOP SLAVE; +RESET SLAVE ALL; +reset master; + +--connection node_3 +reset master; diff --git a/sql/slave.cc b/sql/slave.cc index bf8b8a43b15..c877a1e2c2c 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -306,6 +306,9 @@ handle_slave_background(void *arg __attribute__((unused))) thd->store_globals(); thd->security_ctx->skip_grants(); thd->set_command(COM_DAEMON); +#ifdef WITH_WSREP + thd->variables.wsrep_on= 0; +#endif thd_proc_info(thd, "Loading slave GTID position from table"); if (rpl_load_gtid_slave_state(thd)) @@ -4181,7 +4184,9 @@ pthread_handler_t handle_slave_io(void *arg) goto err; } - +#ifdef WITH_WSREP + thd->variables.wsrep_on= 0; +#endif if (RUN_HOOK(binlog_relay_io, thread_start, (thd, mi))) { mi->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, NULL, diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index 8665a8ae63f..d8f82b13108 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -478,12 +478,29 @@ wsrep_run_wsrep_commit(THD *thd, bool all) if (WSREP_UNDEFINED_TRX_ID == thd->wsrep_ws_handle.trx_id) { - WSREP_WARN("SQL statement was ineffective, THD: %lu, buf: %zu\n" + /* + Async replication slave may have applied some non-innodb workload, + and then has written replication "meta data" into gtid_slave_pos + innodb table. Writes to gtid_slave_pos must not be replicated, + but this activity has caused that innodb hton is registered for this + transaction, but no wsrep keys have been appended. + We enter in this code path, because IO cache has events for non-innodb + tables. + => we should not treat it an error if trx is not introduced for provider + */ + if (thd->system_thread == SYSTEM_THREAD_SLAVE_SQL) + { + WSREP_DEBUG("skipping wsrep replication for async slave, error not raised"); + DBUG_RETURN(WSREP_TRX_OK); + } + + WSREP_WARN("SQL statement was ineffective thd: %lu buf: %zu\n" "schema: %s \n" "QUERY: %s\n" " => Skipping replication", thd->thread_id, data_len, (thd->db ? thd->db : "(null)"), thd->query()); + rcode = WSREP_TRX_FAIL; } else if (!rcode) -- cgit v1.2.1 From 23664bc7a582f03d1ccb680faec8c65f456e0c72 Mon Sep 17 00:00:00 2001 From: Seth Shelnutt Date: Thu, 21 Nov 2019 10:34:36 -0500 Subject: Fix incorrect DBUG_ENTER message for join_read_last --- sql/sql_select.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 55d371bdbfd..ca53852fa91 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -19570,7 +19570,7 @@ join_read_last(JOIN_TAB *tab) { TABLE *table=tab->table; int error= 0; - DBUG_ENTER("join_read_first"); + DBUG_ENTER("join_read_last"); if (table->covering_keys.is_set(tab->index) && !table->no_keyread && !table->key_read) -- cgit v1.2.1 From ed2379f98399ee3ecd6147c6acddfa33e35a9879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Mon, 25 Nov 2019 11:08:13 +0200 Subject: MDEV-13288: Upstream debian patch --- debian/control | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/control b/debian/control index 71329a870c9..fc63c308f75 100644 --- a/debian/control +++ b/debian/control @@ -6,6 +6,7 @@ Uploaders: MariaDB Developers Build-Depends: bison, chrpath, cmake (>= 2.7), + cracklib-runtime, debhelper, dh-apparmor, dpatch, -- cgit v1.2.1 From 427eedd0126de0d9562e843eac911380daa9853c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Tue, 26 Nov 2019 19:52:37 +0200 Subject: MDEV-13288: Proper fix for cracklib-runtime The required dependencies should be added through the autobake script, to also cover distributions that do not support libcrack2. --- debian/autobake-deb.sh | 2 +- debian/control | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index 98071ba6d03..a617995724c 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -41,7 +41,7 @@ then MARIADB_OPTIONAL_DEBS="${MARIADB_OPTIONAL_DEBS} cracklib-password-check-10.1" sed -i -e "/\\\${MAYBE_LIBCRACK}/d" debian/control else - MAYBE_LIBCRACK='libcrack2-dev (>= 2.9.0),' + MAYBE_LIBCRACK='libcrack2-dev (>= 2.9.0), cracklib-runtime' sed -i -e "s/\\\${MAYBE_LIBCRACK}/${MAYBE_LIBCRACK}/g" debian/control fi diff --git a/debian/control b/debian/control index fc63c308f75..71329a870c9 100644 --- a/debian/control +++ b/debian/control @@ -6,7 +6,6 @@ Uploaders: MariaDB Developers Build-Depends: bison, chrpath, cmake (>= 2.7), - cracklib-runtime, debhelper, dh-apparmor, dpatch, -- cgit v1.2.1 From 6218bf1b416219aef37301f054136fcdcc404d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Tue, 26 Nov 2019 21:48:22 +0200 Subject: cracklib-runtime needs a comma after to parse properly --- debian/autobake-deb.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index a617995724c..bfdba96e487 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -41,7 +41,7 @@ then MARIADB_OPTIONAL_DEBS="${MARIADB_OPTIONAL_DEBS} cracklib-password-check-10.1" sed -i -e "/\\\${MAYBE_LIBCRACK}/d" debian/control else - MAYBE_LIBCRACK='libcrack2-dev (>= 2.9.0), cracklib-runtime' + MAYBE_LIBCRACK='libcrack2-dev (>= 2.9.0), cracklib-runtime,' sed -i -e "s/\\\${MAYBE_LIBCRACK}/${MAYBE_LIBCRACK}/g" debian/control fi -- cgit v1.2.1 From 2855edf9ee0344e596ff4b9ee70a23421ae60405 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Sat, 23 Nov 2019 23:26:35 +0700 Subject: try to fix data races in DBUG init_settings.keywords and it's pointee are shared data. Protect them with mutex too. --- dbug/dbug.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/dbug/dbug.c b/dbug/dbug.c index 78605983ccb..21f86ded0a5 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -320,6 +320,10 @@ static void DbugVfprintf(FILE *stream, const char* format, va_list args); */ #include +/* +** Protects writing to all file descriptors, init_settings.keywords +** pointer and it's pointee - a linked list with keywords. +*/ static pthread_mutex_t THR_LOCK_dbug; static void LockMutex(CODE_STATE *cs) @@ -332,6 +336,16 @@ static void UnlockMutex(CODE_STATE *cs) if (!cs->locked) pthread_mutex_unlock(&THR_LOCK_dbug); } +static void LockIfInitSettings(CODE_STATE *cs) +{ + if (cs->stack == &init_settings) + LockMutex(cs); +} +static void UnlockIfInitSettings(CODE_STATE *cs) +{ + if (cs->stack == &init_settings) + UnlockMutex(cs); +} static CODE_STATE *code_state(void) { @@ -476,7 +490,9 @@ static int DbugParse(CODE_STATE *cs, const char *control) stack->sub_level= 0; stack->out_file= sstderr; stack->functions= NULL; + LockIfInitSettings(cs); stack->keywords= NULL; + UnlockIfInitSettings(cs); stack->processes= NULL; } else if (!stack->out_file) @@ -492,7 +508,9 @@ static int DbugParse(CODE_STATE *cs, const char *control) { /* never share with the global parent - it can change under your feet */ stack->functions= ListCopy(init_settings.functions); + LockIfInitSettings(cs); stack->keywords= ListCopy(init_settings.keywords); + UnlockIfInitSettings(cs); stack->processes= ListCopy(init_settings.processes); } else @@ -516,21 +534,31 @@ static int DbugParse(CODE_STATE *cs, const char *control) case 'd': if (sign < 0 && control == end) { + LockIfInitSettings(cs); if (!is_shared(stack, keywords)) FreeList(stack->keywords); stack->keywords=NULL; + UnlockIfInitSettings(cs); stack->flags &= ~DEBUG_ON; break; } + LockIfInitSettings(cs); if (rel && is_shared(stack, keywords)) stack->keywords= ListCopy(stack->keywords); + UnlockIfInitSettings(cs); if (sign < 0) { if (DEBUGGING) + { + LockIfInitSettings(cs); stack->keywords= ListDel(stack->keywords, control, end); + UnlockIfInitSettings(cs); + } break; } + LockIfInitSettings(cs); stack->keywords= ListAdd(stack->keywords, control, end); + UnlockIfInitSettings(cs); stack->flags |= DEBUG_ON; break; case 'D': @@ -997,7 +1025,9 @@ int _db_explain_ (CODE_STATE *cs, char *buf, size_t len) get_code_state_if_not_set_or_return *buf=0; + LockIfInitSettings(cs); op_list_to_buf('d', cs->stack->keywords, DEBUGGING); + UnlockIfInitSettings(cs); op_int_to_buf ('D', cs->stack->delay, 0); op_list_to_buf('f', cs->stack->functions, cs->stack->functions); op_bool_to_buf('F', cs->stack->flags & FILE_ON); @@ -1578,8 +1608,10 @@ static void PushState(CODE_STATE *cs) static void FreeState(CODE_STATE *cs, int free_state) { struct settings *state= cs->stack; + LockIfInitSettings(cs); if (!is_shared(state, keywords)) FreeList(state->keywords); + UnlockIfInitSettings(cs); if (!is_shared(state, functions)) FreeList(state->functions); if (!is_shared(state, processes)) @@ -1702,10 +1734,16 @@ FILE *_db_fp_(void) BOOLEAN _db_keyword_(CODE_STATE *cs, const char *keyword, int strict) { int match= strict ? INCLUDE : INCLUDE|MATCHED; + BOOLEAN result = FALSE; get_code_state_if_not_set_or_return FALSE; - return (DEBUGGING && DoTrace(cs) & DO_TRACE && - InList(cs->stack->keywords, keyword, strict) & match); + if (!DEBUGGING || !(DoTrace(cs) & DO_TRACE)) + return FALSE; + + LockIfInitSettings(cs); + result= (InList(cs->stack->keywords, keyword, strict) & match) ? TRUE : FALSE; + UnlockIfInitSettings(cs); + return result; } /* -- cgit v1.2.1 From 866e5c250e27e32cd295d84988ffdf7ae64503b2 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sun, 11 Feb 2018 14:42:11 +1100 Subject: MDEV-15503: mtr fix --strace $glob_mysql_test_dir was the wrong directory for strace output as it was for in-tree builds only so failed for: * out of tree builds * --parallel; and * --mem strace output wasn't saved. strace-option never replaced existing arguments (so ammended documentation). strace-client didn't accept an argument as described. Replaced specification of client with this with 'stracer' to be consistent with --debugger option. For consistency with debugger options, --client-strace was added to execute the strace on the mysqltest. Example: Running one test $ ./mtr --strace --client-strace funcs_1.is_table_constraints Logging: ./mtr --strace --client-strace funcs_1.is_table_constraints vardir: /home/anel/mariadb/5.5/mysql-test/var Checking leftover processes... Removing old var directory... - WARNING: Using the 'mysql-test/var' symlink Creating var directory '/home/anel/mariadb/5.5/mysql-test/var'... Checking supported features... MariaDB Version 5.5.67-MariaDB-debug Installing system database... - SSL connections supported - binaries are debug compiled Collecting tests... ============================================================================== TEST RESULT TIME (ms) or COMMENT -------------------------------------------------------------------------- worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019 funcs_1.is_table_constraints [ pass ] 1270 -------------------------------------------------------------------------- The servers were restarted 0 times Spent 1.270 of 3 seconds executing testcases Completed: All 1 tests were successful $ find -L . -name \*strace -ls 653 56 -rw-r--r-- 1 anel anel 57147 Nov 29 15:08 ./var/log/mysqltest.strace 646 1768 -rw-r--r-- 1 anel anel 1809855 Nov 29 15:08 ./var/log/mysqld.1.strace Example: Running test in parallel $ mysql-test/mtr --strace --client-strace --mem --parallel=3 main.select Logging: /home/dan/software_projects/mariadb-server/mysql-test/mysql-test-run.pl --strace --client-strace --mem --parallel=3 main.select vardir: /home/dan/software_projects/build-mariadb-10.3/mysql-test/var Checking leftover processes... Removing old var directory... Creating var directory '/home/dan/software_projects/build-mariadb-10.3/mysql-test/var'... - symlinking 'var' to '/dev/shm/var_auto_0v2E' Checking supported features... MariaDB Version 5.5.67-MariaDB - SSL connections supported Collecting tests... Installing system database... ============================================================================== TEST WORKER RESULT TIME (ms) or COMMENT -------------------------------------------------------------------------- worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019 worker[3] - 'localhost:16040' was not free worker[2] Using MTR_BUILD_THREAD 301, with reserved ports 16020..16039 worker[3] Using MTR_BUILD_THREAD 303, with reserved ports 16060..16079 main.select w1 [ pass ] 7310 -------------------------------------------------------------------------- The servers were restarted 0 times Spent 7.310 of 11 seconds executing testcases Completed: All 1 tests were successful. $ find mysql-test/var/ -name \*strace -ls 5213766 1212 -rw-r--r-- 1 dan dan 1237817 May 20 16:47 mysql-test/var/1/log/mysqltest.strace 5214733 13016 -rw-r--r-- 1 dan dan 13328335 May 20 16:47 mysql-test/var/1/log/mysqld.1.strace $ mysql-test/mtr --strace --client-strace --strace-option='-e' --strace-option='trace=openat' --mem --parallel=3 main.select ... $ find mysql-test/var/ -name \*strace -ls 5220790 8 -rw-r--r-- 1 dan dan 6291 May 20 17:02 mysql-test/var/3/log/mysqltest.strace 5224140 308 -rw-r--r-- 1 dan dan 314356 May 20 17:02 mysql-test/var/3/log/mysqld.1.strace $ more mysql-test/var/3/mysqltest.strace 1692 openat(AT_FDCWD, "/home/dan/software_projects/mariadb-server/libmysql/.libs/tls/x86_64/x86_64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 1692 openat(AT_FDCWD, "/home/dan/software_projects/mariadb-server/libmysql/.libs/tls/x86_64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOE NT (No such file or directory) Closes #600 --- mysql-test/mysql-test-run.pl | 48 +++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index e3e9460f35a..8b9d91935bf 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -311,7 +311,8 @@ my $opt_valgrind_mysqltest= 0; my @default_valgrind_args= ("--show-reachable=yes"); my @valgrind_args; my $opt_strace= 0; -my $opt_strace_client; +my $opt_stracer; +my $opt_client_strace = 0; my @strace_args; my $opt_valgrind_path; my $valgrind_reports= 0; @@ -1156,9 +1157,10 @@ sub command_line_setup { 'debugger=s' => \$opt_debugger, 'boot-dbx' => \$opt_boot_dbx, 'client-debugger=s' => \$opt_client_debugger, - 'strace' => \$opt_strace, - 'strace-client' => \$opt_strace_client, - 'strace-option=s' => \@strace_args, + 'strace' => \$opt_strace, + 'strace-option=s' => \@strace_args, + 'client-strace' => \$opt_client_strace, + 'stracer=s' => \$opt_stracer, 'max-save-core=i' => \$opt_max_save_core, 'max-save-datadir=i' => \$opt_max_save_datadir, 'max-test-fail=i' => \$opt_max_test_fail, @@ -1750,7 +1752,7 @@ sub command_line_setup { join(" ", @valgrind_args), "\""); } - if (@strace_args) + if (@strace_args || $opt_stracer) { $opt_strace=1; } @@ -5840,14 +5842,6 @@ sub start_mysqltest ($) { mtr_add_arg($args, "--non-blocking-api"); } - if ( $opt_strace_client ) - { - $exe= $opt_strace_client || "strace"; - mtr_add_arg($args, "-o"); - mtr_add_arg($args, "%s/log/mysqltest.strace", $opt_vardir); - mtr_add_arg($args, "$exe_mysqltest"); - } - mtr_add_arg($args, "--timer-file=%s/log/timer", $opt_vardir); if ( $opt_compress ) @@ -5914,6 +5908,17 @@ sub start_mysqltest ($) { mtr_add_arg($args, "%s", $_) for @args_saved; } + # ---------------------------------------------------------------------- + # Prefix the strace options to the argument list. + # ---------------------------------------------------------------------- + if ( $opt_client_strace ) + { + my @args_saved = @$args; + mtr_init_args(\$args); + strace_arguments($args, \$exe, "mysqltest"); + mtr_add_arg($args, "%s", $_) for @args_saved; + } + if ($opt_force > 1) { mtr_add_arg($args, "--continue-on-error"); @@ -6252,16 +6257,17 @@ sub strace_arguments { my $args= shift; my $exe= shift; my $mysqld_name= shift; + my $output= sprintf("%s/log/%s.strace", $path_vardir_trace, $mysqld_name); mtr_add_arg($args, "-f"); - mtr_add_arg($args, "-o%s/var/log/%s.strace", $glob_mysql_test_dir, $mysqld_name); + mtr_add_arg($args, "-o%s", $output); - # Add strace options, can be overriden by user + # Add strace options mtr_add_arg($args, '%s', $_) for (@strace_args); mtr_add_arg($args, $$exe); - $$exe= "strace"; + $$exe= $opt_stracer || "strace"; if ($exe_libtool) { @@ -6520,11 +6526,11 @@ Options for valgrind Options for strace strace Run the "mysqld" executables using strace. Default - options are -f -o var/log/'mysqld-name'.strace - strace-option=ARGS Option to give strace, replaces default option(s), - strace-client=[path] Create strace output for mysqltest client, optionally - specifying name and path to the trace program to use. - Example: $0 --strace-client=ktrace + options are -f -o 'vardir'/log/'mysqld-name'.strace. + client-strace Trace the "mysqltest". + strace-option=ARGS Option to give strace, appends to existing options. + stracer= Specify name and path to the trace program to use. + Example: $0 --strace-client=ktrace. Misc options user=USER User for connecting to mysqld(default: $opt_user) -- cgit v1.2.1 From 3cb60ec2c305f0b0ab9c3680eb787f8dcd78e57b Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Fri, 29 Nov 2019 15:50:40 +0100 Subject: Update `stracer` description in `mtr`. `strace-client` is not used --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 8b9d91935bf..6d32e97d6b4 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -6530,7 +6530,7 @@ Options for strace client-strace Trace the "mysqltest". strace-option=ARGS Option to give strace, appends to existing options. stracer= Specify name and path to the trace program to use. - Example: $0 --strace-client=ktrace. + Default is "strace". Example: $0 --stracer=ktrace. Misc options user=USER User for connecting to mysqld(default: $opt_user) -- cgit v1.2.1 From 6fe2aae3ce8139864dfe45f2f9834f82ef54ff1e Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Sat, 30 Nov 2019 12:14:00 +0700 Subject: InnoDB: log unsuccessful calls to pthread_attr_init() and pthread_create() before crash --- storage/innobase/os/os0thread.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/storage/innobase/os/os0thread.cc b/storage/innobase/os/os0thread.cc index 792d9cc4e10..ed3f1a13f42 100644 --- a/storage/innobase/os/os0thread.cc +++ b/storage/innobase/os/os0thread.cc @@ -143,7 +143,13 @@ os_thread_create_func( pthread_attr_t attr; #ifndef UNIV_HPUX10 - pthread_attr_init(&attr); + ret = pthread_attr_init(&attr); + if (UNIV_UNLIKELY(ret)) { + fprintf(stderr, + "InnoDB: Error: pthread_attr_init() returned %d\n", + ret); + exit(1); + } #endif #ifdef UNIV_AIX @@ -171,7 +177,11 @@ os_thread_create_func( #else ret = pthread_create(&pthread, &attr, func, arg); #endif - ut_a(ret == 0); + if (UNIV_UNLIKELY(ret)) { + fprintf(stderr, + "InnoDB: Error: pthread_create() returned %d\n", ret); + exit(1); + } #ifndef UNIV_HPUX10 pthread_attr_destroy(&attr); -- cgit v1.2.1 From 33cf4da1838f3f13d8e973e7f46cc486f1183338 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Sat, 30 Nov 2019 18:19:20 +0700 Subject: cleanup: replace exit(1) with abort() --- storage/innobase/os/os0thread.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/storage/innobase/os/os0thread.cc b/storage/innobase/os/os0thread.cc index ed3f1a13f42..1182166f522 100644 --- a/storage/innobase/os/os0thread.cc +++ b/storage/innobase/os/os0thread.cc @@ -148,7 +148,7 @@ os_thread_create_func( fprintf(stderr, "InnoDB: Error: pthread_attr_init() returned %d\n", ret); - exit(1); + abort(); } #endif @@ -165,7 +165,7 @@ os_thread_create_func( fprintf(stderr, "InnoDB: Error: pthread_attr_setstacksize" " returned %d\n", ret); - exit(1); + abort(); } #endif os_mutex_enter(os_sync_mutex); @@ -180,7 +180,7 @@ os_thread_create_func( if (UNIV_UNLIKELY(ret)) { fprintf(stderr, "InnoDB: Error: pthread_create() returned %d\n", ret); - exit(1); + abort(); } #ifndef UNIV_HPUX10 -- cgit v1.2.1 From d930422e9e84aa1bc265963225dd29295203e9d3 Mon Sep 17 00:00:00 2001 From: Faustin Lammler Date: Fri, 29 Nov 2019 13:21:23 +0100 Subject: Fix the line break warning (groff/lintian). The lintian Debian tool is complaining about: 'W: mariadb-test: manpage-has-errors-from-man usr/share/man/man1/mysql-test-run.pl.1.gz 246: warning [p 2, 6.0i, div '3tbd1,1', 0.3i]: can't break line' See: https://salsa.debian.org/faust-guest/mariadb-10.3/-/jobs/431900 The following command permits to catch the problematic lines: $ groff -man -Tascii ./mysql-test-run.pl.1 | less Closes #1419 --- man/mysql-test-run.pl.1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/man/mysql-test-run.pl.1 b/man/mysql-test-run.pl.1 index 8b8eafd7bdd..abf1d1bc240 100644 --- a/man/mysql-test-run.pl.1 +++ b/man/mysql-test-run.pl.1 @@ -1937,8 +1937,10 @@ Run stress test, providing options to mysql\-stress\-test\&.pl\&. Options are se .\" suite option: mysql-test-run.pl \fB\-\-suite[s]=\fR\fB\fIsuite_name...\fR\fR .sp -Comma separated list of suite names to run. The default is: "main-,archive-,binlog-,csv-,federated-,funcs_1-,funcs_2-,handler-,heap-,innodb-,innodb_fts-, -innodb_zip-,maria-,multi_source-,optimizer_unfixed_bugs-,parts-,percona-,perfschema-, +Comma separated list of suite names to run. The default is: +"main-,archive-,binlog-,csv-,federated-,funcs_1-,funcs_2-, +handler-,heap-,innodb-,innodb_fts-,innodb_zip-,maria-, +multi_source-,optimizer_unfixed_bugs-,parts-,perfschema-, plugins-,roles-,rpl-,sys_vars-,unit-,vcol-"\&. .RE .sp -- cgit v1.2.1 From e3d3bbf59829e93e83ab05d831e92a742ffd7e32 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Thu, 28 Nov 2019 15:08:29 +0100 Subject: Using `variables` instead of `values` in mysqld --help documentation would be more accurate --- mysql-test/r/mysqld--help.result | 2 +- scripts/mysql_install_db.sh | 2 +- sql/mysqld.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result index 825c7e786a3..bececa14d7a 100644 --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result @@ -1107,5 +1107,5 @@ userstat FALSE verbose TRUE wait-timeout 28800 -To see what values a running MySQL server is using, type +To see what variables a running MySQL server is using, type 'mysqladmin variables' instead of 'mysqld --verbose --help'. diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index fb1663d9d69..fe7375494fe 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -214,7 +214,7 @@ cannot_find_file() echo "If you compiled from source, you need to either run 'make install' to" echo "copy the software into the correct location ready for operation." echo "If you don't want to do a full install, you can use the --srcdir" - echo "option to only install the mysql database and privilege tables" + echo "option to only install the mysql database and privilege tables." echo echo "If you are using a binary release, you must either be at the top" echo "level of the extracted archive, or pass the --basedir option" diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 96daeab867d..2aedec595c0 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -7240,7 +7240,7 @@ because execution stopped before plugins were initialized."); } puts("\n\ -To see what values a running MySQL server is using, type\n\ +To see what variables a running MySQL server is using, type\n\ 'mysqladmin variables' instead of 'mysqld --verbose --help'."); } DBUG_VOID_RETURN; -- cgit v1.2.1