Skip to content

Commit ee455e6

Browse files
committed
Merge 10.3 into 10.4
2 parents 0d267f7 + 6f27130 commit ee455e6

File tree

9 files changed

+324
-19
lines changed

9 files changed

+324
-19
lines changed

mysql-test/collections/smoke_test

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
archive.archive
2+
archive.archive_gis
3+
archive.partition_archive
4+
binlog.binlog_base64_flag
5+
binlog.binlog_database
6+
binlog.binlog_innodb
7+
binlog.binlog_parallel_replication_marks_stm_mix
8+
binlog.binlog_row_mix_innodb_myisam
9+
binlog.flashback
10+
binlog_encryption.encrypted_slave
11+
connect.bin
12+
connect.bson
13+
connect.dbf
14+
connect.dir
15+
connect.endian
16+
connect.general
17+
connect.json
18+
connect.mysql
19+
connect.secure_file_priv
20+
connect.tbl
21+
csv.csv
22+
disks.disks
23+
encryption.encryption_force
24+
encryption.innodb_encryption_tables
25+
encryption.tempfiles_encrypted
26+
federated.federated
27+
federated.federatedx
28+
gcol.gcol_select_innodb
29+
handler.interface
30+
heap.heap
31+
innodb.innodb
32+
innodb.autoinc_persist
33+
innodb.innodb_defrag_binlog
34+
innodb.innodb_mysql
35+
innodb.monitor
36+
innodb.purge
37+
innodb.table_flags
38+
innodb.xa_recovery
39+
innodb_fts.fulltext
40+
innodb_gis.geometry
41+
innodb_gis.rtree
42+
innodb_zip.innodb-zip
43+
innodb_zip.page_size
44+
json.json_no_table
45+
main.blackhole
46+
main.bootstrap
47+
main.compress
48+
main.connect
49+
main.ctype_collate
50+
main.ctype_utf8
51+
main.default
52+
main.dyncol
53+
main.fulltext
54+
main.function_defaults
55+
main.gis
56+
main.grant
57+
main.handlersocket
58+
main.information_schema
59+
main.innodb_ext_key
60+
main.log_tables
61+
main.lowercase_fs_off
62+
main.myisam
63+
main.mysql_client_test
64+
main.mysql_protocols
65+
main.mysql_upgrade
66+
main.mysqladmin
67+
main.mysqlbinlog
68+
main.mysqlcheck
69+
main.mysqld--defaults-file
70+
main.mysqldump
71+
main.mysqlhotcopy_myisam
72+
main.mysqlshow
73+
main.mysqlslap
74+
main.mysqltest
75+
main.parser
76+
main.partition
77+
main.perror
78+
main.plugin
79+
main.plugin_auth
80+
main.pool_of_threads
81+
main.ps
82+
main.repair
83+
main.shutdown
84+
main.sp
85+
main.ssl
86+
main.ssl_compress
87+
main.stat_tables
88+
main.statistics
89+
main.subselect
90+
main.symlink
91+
main.temp_table
92+
main.timezone
93+
main.type_timestamp_hires
94+
main.user_var
95+
main.userstat
96+
main.variables
97+
main.view
98+
main.win
99+
main.xa
100+
maria.maria
101+
mariabackup.full_backup
102+
metadata_lock_info.table_metadata_lock
103+
mroonga/storage.variable_version
104+
mroonga/wrapper.count_star
105+
multi_source.multisource
106+
oqgraph.general-innodb
107+
parts.rpl_partition
108+
perfschema.selects
109+
plugins.auth_ed25519
110+
plugins.cracklib_password_check
111+
plugins.dialog
112+
plugins.fulltext_plugin
113+
plugins.locales
114+
plugins.pam_cleartext
115+
plugins.processlist
116+
plugins.qc_info
117+
plugins.server_audit
118+
plugins.simple_password_check
119+
plugins.sql_error_log
120+
plugins.two_password_validations
121+
plugins.unix_socket
122+
query_response_time.basic
123+
rocksdb.rocksdb
124+
roles.definer
125+
rpl.rpl_gtid_basic
126+
rpl.rpl_relayrotate
127+
rpl.rpl_row_blob_innodb
128+
rpl.rpl_semi_sync_event
129+
rpl.rpl_sp
130+
rpl.rpl_stm_binlog_max_cache_size
131+
rpl.rpl_switch_stm_row_mixed
132+
sequence.simple
133+
spider.basic_sql
134+
spider.ha
135+
sql_discovery.simple
136+
sys_vars.sysvars_aria
137+
sys_vars.sysvars_server_notembedded
138+
wsrep.variables
139+
compat/oracle.binlog_ptr_mysqlbinlog
140+
compat/oracle.sp-package
141+
compat/maxdb.rpl_mariadb_timestamp
142+
sql_sequence.mysqldump
143+
versioning.simple
144+
versioning.trx_id
145+
period.versioning
146+
plugins.multiauth
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
SET GLOBAL innodb_flush_log_at_trx_commit= 1;
2+
RESET MASTER;
3+
CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb;
4+
*** Test that FLUSH LOGS waits if a transaction ordered commit is in progress.
5+
connect con1,localhost,root,,;
6+
SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL con1_ready WAIT_FOR con1_go";
7+
INSERT INTO t1 VALUES (1, REPEAT("x", 1));
8+
connection default;
9+
SET DEBUG_SYNC= "now WAIT_FOR con1_ready";
10+
SET DEBUG_SYNC= "rotate_after_rotate SIGNAL con_flush_ready WAIT_FOR default_go";
11+
FLUSH LOGS;
12+
connect con2,localhost,root,,;
13+
Trx_1 is not yet committed:
14+
SELECT count(*) as 'ZERO' from t1;
15+
ZERO
16+
0
17+
Wait for Trx_2 has rotated binlog:
18+
SET DEBUG_SYNC= "now WAIT_FOR con_flush_ready";
19+
SET DEBUG_SYNC= "now SIGNAL default_go";
20+
# restart
21+
connection default;
22+
Must be tree logs in the list:
23+
show binary logs;
24+
Log_name File_size
25+
master-bin.000001 #
26+
master-bin.000002 #
27+
master-bin.000003 #
28+
include/show_binlog_events.inc
29+
Log_name Pos Event_type Server_id End_log_pos Info
30+
master-bin.000001 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
31+
master-bin.000001 # Gtid_list # # []
32+
master-bin.000001 # Binlog_checkpoint # # master-bin.000001
33+
master-bin.000001 # Gtid # # GTID #-#-#
34+
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb
35+
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
36+
master-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (1, REPEAT("x", 1))
37+
master-bin.000001 # Table_map # # table_id: # (test.t1)
38+
master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
39+
master-bin.000001 # Xid # # COMMIT /* XID */
40+
master-bin.000001 # Rotate # # master-bin.000002;pos=POS
41+
Only one Binlog checkpoint must exist and point to master-bin.000001
42+
include/show_binlog_events.inc
43+
Log_name Pos Event_type Server_id End_log_pos Info
44+
master-bin.000002 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
45+
master-bin.000002 # Gtid_list # # [#-#-#]
46+
master-bin.000002 # Binlog_checkpoint # # master-bin.000001
47+
SELECT count(*) as 'ONE' from t1;
48+
ONE
49+
1
50+
connection default;
51+
DROP TABLE t1;
52+
SET debug_sync = 'reset';
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
--source include/have_innodb.inc
2+
--source include/have_debug.inc
3+
--source include/have_debug_sync.inc
4+
--source include/have_binlog_format_row.inc
5+
6+
# References:
7+
#
8+
# MDEV-24526 binlog rotate via FLUSH LOGS may obsolate binlog file too eary
9+
#
10+
# The test for MDEV-24526 proves the fixes correct observed race condition
11+
# between a commiting transaction and FLUSH-LOGS.
12+
# The plot.
13+
# Trx_1 (con1) transaction binlogs first
14+
# to yield its turn acquiring LOCK_commit_ordered to Trx_2 and stand
15+
# still waiting of a signal that will never arrive.
16+
# Trx_2 can't acquire it in the fixed version even though
17+
# Trx_3 makes sure Trx_2 has reached a post-rotation execution point
18+
# to signal it to proceed.
19+
# Then the server gets crashed and Trx_1 must recover unlike
20+
# in the OLD buggy version.
21+
#
22+
SET GLOBAL innodb_flush_log_at_trx_commit= 1;
23+
RESET MASTER;
24+
25+
CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb;
26+
27+
--echo *** Test that FLUSH LOGS waits if a transaction ordered commit is in progress.
28+
29+
connect(con1,localhost,root,,); # Trx_1
30+
# hang before doing acquiring Commit Ordered mutex
31+
SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL con1_ready WAIT_FOR con1_go";
32+
33+
--send INSERT INTO t1 VALUES (1, REPEAT("x", 1))
34+
35+
connection default; # Trx_2
36+
37+
SET DEBUG_SYNC= "now WAIT_FOR con1_ready";
38+
SET DEBUG_SYNC= "rotate_after_rotate SIGNAL con_flush_ready WAIT_FOR default_go";
39+
--send FLUSH LOGS
40+
41+
connect(con2,localhost,root,,); # Trx_3
42+
--echo Trx_1 is not yet committed:
43+
SELECT count(*) as 'ZERO' from t1;
44+
45+
--echo Wait for Trx_2 has rotated binlog:
46+
SET DEBUG_SYNC= "now WAIT_FOR con_flush_ready";
47+
# Useless signal to prove Trx_2 cannot race Trx_1's commit
48+
# even though Trx_1 never received the being waited 'con1_go'.
49+
SET DEBUG_SYNC= "now SIGNAL default_go";
50+
51+
--let $shutdown_timeout=0
52+
--source include/restart_mysqld.inc
53+
54+
connection default;
55+
--enable_reconnect
56+
--error 0,2013
57+
--reap
58+
59+
--echo Must be tree logs in the list:
60+
--source include/show_binary_logs.inc
61+
--let $binlog_file= master-bin.000001
62+
--let $binlog_start= 4
63+
--source include/show_binlog_events.inc
64+
65+
--echo Only one Binlog checkpoint must exist and point to master-bin.000001
66+
--let $binlog_file= master-bin.000002
67+
--let $binlog_start= 4
68+
--source include/show_binlog_events.inc
69+
70+
71+
# In the buggy server version the following select may have
72+
# resulted with ZERO:
73+
SELECT count(*) as 'ONE' from t1;
74+
75+
# Clean up.
76+
connection default;
77+
78+
DROP TABLE t1;
79+
SET debug_sync = 'reset';

sql/event_data_objects.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ Event_queue_element_for_exec::init(const LEX_CSTRING *db, const LEX_CSTRING *n)
180180
if (!(name.str= my_strndup(n->str, name.length= n->length, MYF(MY_WME))))
181181
{
182182
my_free(const_cast<char*>(dbname.str));
183+
dbname.str= NULL;
183184
return TRUE;
184185
}
185186
return FALSE;

sql/event_data_objects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct TABLE;
3333
class Event_queue_element_for_exec
3434
{
3535
public:
36-
Event_queue_element_for_exec(){};
36+
Event_queue_element_for_exec() : dbname{nullptr, 0}, name{nullptr, 0} {}
3737
~Event_queue_element_for_exec();
3838

3939
bool

sql/event_queue.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ Event_queue::get_top_for_execution_if_time(THD *thd,
639639
if (!(*event_name= new Event_queue_element_for_exec()) ||
640640
(*event_name)->init(&top->dbname, &top->name))
641641
{
642+
delete *event_name;
642643
ret= TRUE;
643644
break;
644645
}

sql/log.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6984,6 +6984,9 @@ int MYSQL_BIN_LOG::rotate_and_purge(bool force_rotate,
69846984
bool check_purge= false;
69856985

69866986
mysql_mutex_lock(&LOCK_log);
6987+
6988+
DEBUG_SYNC(current_thd, "rotate_after_acquire_LOCK_log");
6989+
69876990
prev_binlog_id= current_binlog_id;
69886991

69896992
if ((err_gtid= do_delete_gtid_domain(domain_drop_lex)))
@@ -6994,11 +6997,22 @@ int MYSQL_BIN_LOG::rotate_and_purge(bool force_rotate,
69946997
}
69956998
else if (unlikely((error= rotate(force_rotate, &check_purge))))
69966999
check_purge= false;
7000+
7001+
DEBUG_SYNC(current_thd, "rotate_after_rotate");
7002+
69977003
/*
69987004
NOTE: Run purge_logs wo/ holding LOCK_log because it does not need
69997005
the mutex. Otherwise causes various deadlocks.
7006+
Explicit binlog rotation must be synchronized with a concurrent
7007+
binlog ordered commit, in particular not let binlog
7008+
checkpoint notification request until early binlogged
7009+
concurrent commits have has been completed.
70007010
*/
7011+
mysql_mutex_lock(&LOCK_after_binlog_sync);
70017012
mysql_mutex_unlock(&LOCK_log);
7013+
mysql_mutex_lock(&LOCK_commit_ordered);
7014+
mysql_mutex_unlock(&LOCK_after_binlog_sync);
7015+
mysql_mutex_unlock(&LOCK_commit_ordered);
70027016

70037017
if (check_purge)
70047018
checkpoint_and_purge(prev_binlog_id);
@@ -8199,7 +8213,12 @@ MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader)
81998213
}
82008214

82018215
DEBUG_SYNC(leader->thd, "commit_before_get_LOCK_commit_ordered");
8216+
82028217
mysql_mutex_lock(&LOCK_commit_ordered);
8218+
DBUG_EXECUTE_IF("crash_before_engine_commit",
8219+
{
8220+
DBUG_SUICIDE();
8221+
});
82038222
last_commit_pos_offset= commit_offset;
82048223

82058224
/*

0 commit comments

Comments
 (0)