Skip to content

Commit 567c097

Browse files
committed
MDEV-33582 Add more warnings to be able to better diagnose network issues
Warnings are added to net_server.cc when global_system_variables.log_warnings >= 4. When the above condition holds then: - All communication errors from net_serv.cc is also written to the error log. - In case of a of not being able to read or write a packet, a more detailed error is given. Other things: - Added detection of slaves that has hangup to Ack_receiver::run() - vio_close() is now first marking the socket closed before closing it. The reason for this is to ensure that the connection that gets a read error can check if the reason was that the socket was closed. - Add a new state to vio to be able to detect if vio is acive, shutdown or closed. This is used to detect if socket is closed by another thread. - Testing of the new warnings is done in rpl_get_lock.test - Suppress some of the new warnings in mtr to allow one to run some of the tests with -mysqld=--log-warnings=4. All test in the 'rpl' suite can now be run with this option. - Ensure that global.log_warnings are restored at test end in a way that allows one to use mtr --mysqld=--log-warnings=4. Reviewed-by: <serg@mariadb.org>,<brandon.nesterenko@mariadb.com>
1 parent 48f42ab commit 567c097

40 files changed

+211
-53
lines changed

include/my_global.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,7 @@ typedef struct st_mysql_lex_string LEX_STRING;
962962
#define SOCKET_ECONNRESET WSAECONNRESET
963963
#define SOCKET_ENFILE ENFILE
964964
#define SOCKET_EMFILE EMFILE
965+
#define SOCKET_CLOSED EIO
965966
#else /* Unix */
966967
#define socket_errno errno
967968
#define closesocket(A) close(A)
@@ -971,6 +972,7 @@ typedef struct st_mysql_lex_string LEX_STRING;
971972
#define SOCKET_EADDRINUSE EADDRINUSE
972973
#define SOCKET_ETIMEDOUT ETIMEDOUT
973974
#define SOCKET_ECONNRESET ECONNRESET
975+
#define SOCKET_CLOSED EIO
974976
#define SOCKET_ENFILE ENFILE
975977
#define SOCKET_EMFILE EMFILE
976978
#endif

include/violite.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ enum enum_vio_type
4141
VIO_TYPE_SSL
4242
/* see also vio_type_names[] */
4343
};
44+
45+
enum enum_vio_state
46+
{
47+
VIO_STATE_NOT_INITIALIZED, VIO_STATE_ACTIVE, VIO_STATE_SHUTDOWN,
48+
VIO_STATE_CLOSED
49+
};
50+
4451
#define FIRST_VIO_TYPE VIO_CLOSED
4552
#define LAST_VIO_TYPE VIO_TYPE_SSL
4653

@@ -244,6 +251,7 @@ struct st_vio
244251
struct sockaddr_storage local; /* Local internet address */
245252
struct sockaddr_storage remote; /* Remote internet address */
246253
enum enum_vio_type type; /* Type of connection */
254+
enum enum_vio_state state; /* State of the connection */
247255
const char *desc; /* String description */
248256
char *read_buffer; /* buffer for vio_read_buff */
249257
char *read_pos; /* start of unfetched data in the

mysql-test/mariadb-test-run.pl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4486,6 +4486,13 @@ ($$)
44864486
qr/Slave I\/0: Master command COM_BINLOG_DUMP failed/,
44874487
qr/Error reading packet/,
44884488
qr/Lost connection to MariaDB server at 'reading initial communication packet'/,
4489+
qr/Could not read packet:.* state: [2-3] /,
4490+
qr/Could not read packet:.* errno: 104 /,
4491+
qr/Could not read packet:.* errno: 0 .* length: 0/,
4492+
qr/Could not write packet:.* errno: 32 /,
4493+
qr/Could not write packet:.* errno: 104 /,
4494+
qr/Semisync ack receiver got error 1158/,
4495+
qr/Connection was killed/,
44894496
qr/Failed on request_dump/,
44904497
qr/Slave: Can't drop database.* database doesn't exist/,
44914498
qr/Slave: Operation DROP USER failed for 'create_rout_db'/,

mysql-test/suite/binlog_encryption/rpl_packet.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ include/master-slave.inc
22
[connection master]
33
call mtr.add_suppression("Slave I/O: Got a packet bigger than 'slave_max_allowed_packet' bytes, .*error.* 1153");
44
call mtr.add_suppression("Log entry on master is longer than slave_max_allowed_packet");
5+
call mtr.add_suppression("Could not write packet:");
6+
call mtr.add_suppression("Got a packet bigger than 'max_allowed_packet' bytes");
57
drop database if exists DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________;
68
create database DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________;
79
connection master;

mysql-test/suite/rpl/include/rpl_extra_col_master.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
#VARCHAR(M)
6060
#
6161

62+
--disable_query_log
63+
call mtr.add_suppression("Could not read packet:.* errno: 11");
64+
--enable_query_log
65+
6266
--let $_saved_conn= $CURRENT_CONNECTION
6367

6468
let $binformat = `SHOW VARIABLES LIKE '%binlog_format%'`;

mysql-test/suite/rpl/r/rpl_binlog_dump_slave_gtid_state_info.result

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
include/master-slave.inc
22
[connection master]
33
connection master;
4+
SET @org_log_warnings=@@GLOBAL.LOG_WARNINGS;
45
SET GLOBAL LOG_WARNINGS=2;
56
connection slave;
67
include/stop_slave.inc
@@ -41,11 +42,11 @@ connection master;
4142
include/wait_for_pattern_in_file.inc
4243
FOUND 1 /using_gtid\(1\), gtid\(\'0-1-2,10-1-1\'\).*/ in mysqld.1.err
4344
"===== Clean up ====="
45+
SET GLOBAL LOG_WARNINGS=@org_log_warnings;
4446
connection slave;
4547
include/stop_slave.inc
4648
CHANGE MASTER TO MASTER_USE_GTID=no;
4749
include/start_slave.inc
4850
connection master;
4951
DROP TABLE t;
50-
SET GLOBAL LOG_WARNINGS=default;
5152
include/rpl_end.inc

mysql-test/suite/rpl/r/rpl_domain_id_filter_master_crash.result

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
include/master-slave.inc
22
[connection master]
33
connection master;
4-
call mtr.add_suppression("mysqld: Table '.*gtid_slave_pos' is marked as crashed and should be repaired");
5-
call mtr.add_suppression("Checking table: './mysql/gtid_slave_pos'");
6-
call mtr.add_suppression("mysql.gtid_slave_pos: 1 client is using or hasn't closed the table properly");
74
SET @@session.gtid_domain_id= 0;
85
create table ti (a int auto_increment primary key) engine=innodb;
96
create table tm (a int auto_increment primary key) engine=myisam;

mysql-test/suite/rpl/r/rpl_get_lock.result

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
include/master-slave.inc
22
[connection master]
3-
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
3+
SET GLOBAL LOG_WARNINGS=4;
44
create table t1(n int);
55
insert into t1 values(get_lock("lock",2));
66
disconnect master;
@@ -35,4 +35,5 @@ NULL
3535
connection master1;
3636
drop table t1;
3737
connection slave;
38+
connection default;
3839
include/rpl_end.inc

mysql-test/suite/rpl/r/rpl_gtid_crash.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ connection server_1;
44
call mtr.add_suppression("Checking table:");
55
call mtr.add_suppression("client is using or hasn't closed the table properly");
66
call mtr.add_suppression("Table .* is marked as crashed and should be repaired");
7+
call mtr.add_suppression("Could not read packet:.* errno: 11");
78
flush tables;
89
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
910
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;

mysql-test/suite/rpl/r/rpl_gtid_grouping.result

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,4 @@ CHANGE MASTER TO MASTER_USE_GTID=no;
5050
include/start_slave.inc
5151
connection master;
5252
DROP TABLE t;
53-
SET GLOBAL LOG_WARNINGS=default;
5453
include/rpl_end.inc

0 commit comments

Comments
 (0)