Skip to content

Commit 6f8ece1

Browse files
author
Justin Jose
committed
Merge branch 'mysql-8.0' into mysql-8.4
Change-Id: I2177201a6a55d24ba3d76ca350d3836ef8cef149
2 parents 8a61ae2 + 2c3bacc commit 6f8ece1

9 files changed

+190
-82
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
include/only_with_option.inc [GLOBAL.replica_transaction_retries > 1]
2+
#
3+
# 1. Create source-replica topology
4+
include/rpl/init_source_replica.inc
5+
Warnings:
6+
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
7+
Note #### Storing MySQL user name or password information in the connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA Syntax' in the MySQL Manual for more information.
8+
[connection master]
9+
[connection slave]
10+
CALL mtr.add_suppression('A replica with the same server_uuid/server_id as this replica has connected to the source.*');
11+
#
12+
# 2. Copy test relay-log files to replica data directory
13+
#
14+
# 3. Create a new channel on replica
15+
CHANGE REPLICATION SOURCE TO RELAY_LOG_FILE='replicate-relay-bin.000001', RELAY_LOG_POS=4, SOURCE_USER='root', SOURCE_HOST='127.0.0.1', SOURCE_PORT=MASTER_PORT FOR CHANNEL 'PITR';
16+
Warnings:
17+
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
18+
Note 1760 Storing MySQL user name or password information in the connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA Syntax' in the MySQL Manual for more information.
19+
#
20+
# 4. Add a debug point to simulate replica retry transaction
21+
# Adding debug point 'simulate_error_ha_delete_row_lock_wait_timeout' to @@GLOBAL.debug
22+
#
23+
# 5. Start replica
24+
include/rpl/start_replica.inc [FOR CHANNEL 'PITR']
25+
include/rpl/assert_replica_running.inc [FOR CHANNEL 'PITR']
26+
include/rpl/assert_replica_no_error.inc [FOR CHANNEL 'PITR']
27+
#
28+
# 6. Wait till replica apply all txns successfully
29+
include/rpl/wait_for_replica_status.inc [Replica_SQL_Running_State FOR CHANNEL 'PITR']
30+
#
31+
# 7. Verify that there is a retry transaction warning
32+
include/assert_grep.inc [Found error message regarding retry transaction]
33+
#
34+
# 8. Cleanup
35+
# Removing debug point 'simulate_error_ha_delete_row_lock_wait_timeout' from @@GLOBAL.debug
36+
include/rpl/stop_replica.inc [FOR CHANNEL 'PITR']
37+
RESET REPLICA ALL FOR CHANNEL 'PITR';
38+
include/rpl/start_replica.inc
39+
include/rpl/deinit.inc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
##############################################################################
2+
# ==== Purpose ====
3+
# The purpose of this test is to verify that, when an issue occurs in the
4+
# applier and it identifies the transaction can be retried, applier uses
5+
# relay log file name mentioned in the index file instead of calculating
6+
# the file name based on the configured server option(--relay-log).
7+
#
8+
# ==== Requirement ====
9+
# When an issue occurs in the applier and it identifies the transaction can
10+
# be retired, the applier should use the relaylog file name mentioned in the
11+
# index file instead of calculating the file name from the configured
12+
# server option.
13+
#
14+
# ==== Implementation ====
15+
# 1. Create source-replica topology
16+
# 2. Copy test relay-log files to replica data directory
17+
# 3. Create a new channel on replica
18+
# 4. Add a debug point to simulate replica retry transaction
19+
# 5. Start replica
20+
# 6. Wait till replica apply all txns successfully
21+
# 7. Verify that there is a retry transaction warning
22+
# 8. Clean up
23+
#
24+
# ==== References ====
25+
# BUG#36395631:Replica applier retries ignore the relay log index file
26+
###############################################################################
27+
28+
29+
--source include/have_debug.inc
30+
--source include/have_binlog_format_row.inc
31+
--let $option_name = replica_transaction_retries
32+
--let $option_operator = >
33+
--let $option_value = 1
34+
--source include/only_with_option.inc
35+
36+
--echo #
37+
--echo # 1. Create source-replica topology
38+
--let $rpl_skip_start_slave=1
39+
--source include/rpl/init_source_replica.inc
40+
41+
--source include/rpl/connection_replica.inc
42+
CALL mtr.add_suppression('A replica with the same server_uuid/server_id as this replica has connected to the source.*');
43+
44+
--echo #
45+
--echo # 2. Copy test relay-log files to replica data directory
46+
--let $datadir= `SELECT @@datadir`
47+
--copy_file $MYSQL_TEST_DIR/std_data/replicated-bin.000001 $datadir/replicate-relay-bin.000001
48+
--copy_file $MYSQL_TEST_DIR/std_data/replicated-bin.000002 $datadir/replicate-relay-bin.000002
49+
--copy_file $MYSQL_TEST_DIR/std_data/replicated-bin.index $datadir/slave-relay-bin-pitr.index
50+
51+
--echo #
52+
--echo # 3. Create a new channel on replica
53+
--replace_result $MASTER_MYPORT MASTER_PORT
54+
--eval CHANGE REPLICATION SOURCE TO RELAY_LOG_FILE='replicate-relay-bin.000001', RELAY_LOG_POS=4, SOURCE_USER='root', SOURCE_HOST='127.0.0.1', SOURCE_PORT=$MASTER_MYPORT FOR CHANNEL 'PITR'
55+
56+
--echo #
57+
--echo # 4. Add a debug point to simulate replica retry transaction
58+
--let $debug_point= simulate_error_ha_delete_row_lock_wait_timeout
59+
--source include/add_debug_point.inc
60+
61+
--echo #
62+
--echo # 5. Start replica
63+
--let $rpl_channel_name= 'PITR'
64+
--source include/rpl/start_replica.inc
65+
--source include/rpl/assert_replica_running.inc
66+
--source include/rpl/assert_replica_no_error.inc
67+
68+
--echo #
69+
--echo # 6. Wait till replica apply all txns successfully
70+
--let $slave_param= Replica_SQL_Running_State
71+
--let $slave_param_value= Replica has read all relay log; waiting for more updates
72+
--source include/rpl/wait_for_replica_status.inc
73+
74+
--echo #
75+
--echo # 7. Verify that there is a retry transaction warning
76+
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
77+
--let $assert_match= Error 'Lock wait timeout exceeded; try restarting transaction' on query
78+
--let $assert_select= Replica SQL
79+
--let $assert_text= Found error message regarding retry transaction
80+
--source include/assert_grep.inc
81+
82+
--echo #
83+
--echo # 8. Cleanup
84+
--let $debug_point= simulate_error_ha_delete_row_lock_wait_timeout
85+
--source include/remove_debug_point.inc
86+
87+
--let $rpl_channel_name= 'PITR'
88+
--source include/rpl/stop_replica.inc
89+
90+
RESET REPLICA ALL FOR CHANNEL 'PITR';
91+
92+
--let $rpl_channel_name=
93+
source include/rpl/start_replica.inc;
94+
95+
--source include/rpl/deinit.inc

sql/handler.cc

+4
Original file line numberDiff line numberDiff line change
@@ -8113,6 +8113,10 @@ int handler::ha_delete_row(const uchar *buf) {
81138113
*/
81148114
assert(buf == table->record[0] || buf == table->record[1]);
81158115
DBUG_EXECUTE_IF("inject_error_ha_delete_row", return HA_ERR_INTERNAL_ERROR;);
8116+
DBUG_EXECUTE_IF("simulate_error_ha_delete_row_lock_wait_timeout", {
8117+
DBUG_SET("-d,simulate_error_ha_delete_row_lock_wait_timeout");
8118+
return HA_ERR_LOCK_WAIT_TIMEOUT;
8119+
});
81168120

81178121
DBUG_EXECUTE_IF(
81188122
"handler_crashed_table_on_usage",

sql/log_event.cc

+13-8
Original file line numberDiff line numberDiff line change
@@ -2628,8 +2628,10 @@ Slave_worker *Log_event::get_slave_worker(Relay_log_info *rli) {
26282628
!is_mts_db_partitioned(rli));
26292629

26302630
if (is_s_event || is_any_gtid_event(this)) {
2631-
Slave_job_item job_item = {this, rli->get_event_relay_log_number(),
2632-
rli->get_event_start_pos()};
2631+
Slave_job_item job_item = {this, rli->get_event_start_pos(), {'\0'}};
2632+
if (rli->get_event_relay_log_name())
2633+
strcpy(job_item.event_relay_log_name,
2634+
rli->get_event_relay_log_name());
26332635
// B-event is appended to the Deferred Array associated with GCAP
26342636
rli->curr_group_da.push_back(job_item);
26352637

@@ -2664,8 +2666,9 @@ Slave_worker *Log_event::get_slave_worker(Relay_log_info *rli) {
26642666
TODO: Make GITD event as B-event that is starts_group() to
26652667
return true.
26662668
*/
2667-
Slave_job_item job_item = {this, rli->get_event_relay_log_number(),
2668-
rli->get_event_relay_log_pos()};
2669+
Slave_job_item job_item = {this, rli->get_event_relay_log_pos(), {'\0'}};
2670+
if (rli->get_event_relay_log_name())
2671+
strcpy(job_item.event_relay_log_name, rli->get_event_relay_log_name());
26692672

26702673
// B-event is appended to the Deferred Array associated with GCAP
26712674
rli->curr_group_da.push_back(job_item);
@@ -2693,8 +2696,9 @@ Slave_worker *Log_event::get_slave_worker(Relay_log_info *rli) {
26932696
rli, &rli->workers, this);
26942697
if (ret_worker == nullptr) {
26952698
/* get_least_occupied_worker may return NULL if the thread is killed */
2696-
Slave_job_item job_item = {this, rli->get_event_relay_log_number(),
2697-
rli->get_event_start_pos()};
2699+
Slave_job_item job_item = {this, rli->get_event_start_pos(), {'\0'}};
2700+
if (rli->get_event_relay_log_name())
2701+
strcpy(job_item.event_relay_log_name, rli->get_event_relay_log_name());
26982702
rli->curr_group_da.push_back(job_item);
26992703

27002704
assert(thd->killed);
@@ -2845,8 +2849,9 @@ Slave_worker *Log_event::get_slave_worker(Relay_log_info *rli) {
28452849
Their association with relay-log physical coordinates is provided
28462850
by the same mechanism that applies to a regular event.
28472851
*/
2848-
Slave_job_item job_item = {this, rli->get_event_relay_log_number(),
2849-
rli->get_event_start_pos()};
2852+
Slave_job_item job_item = {this, rli->get_event_start_pos(), {'\0'}};
2853+
if (rli->get_event_relay_log_name())
2854+
strcpy(job_item.event_relay_log_name, rli->get_event_relay_log_name());
28502855
rli->curr_group_da.push_back(job_item);
28512856

28522857
assert(!ret_worker);

sql/rpl_replica.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -4524,8 +4524,9 @@ apply_event_and_update_pos(Log_event **ptr_ev, THD *thd, Relay_log_info *rli) {
45244524

45254525
if (!exec_res && (ev->worker != rli)) {
45264526
if (ev->worker) {
4527-
Slave_job_item item = {ev, rli->get_event_relay_log_number(),
4528-
rli->get_event_start_pos()};
4527+
Slave_job_item item = {ev, rli->get_event_start_pos(), {'\0'}};
4528+
if (rli->get_event_relay_log_name())
4529+
strcpy(item.event_relay_log_name, rli->get_event_relay_log_name());
45294530
Slave_job_item *job_item = &item;
45304531
Slave_worker *w = (Slave_worker *)ev->worker;
45314532
// specially marked group typically with OVER_MAX_DBS_IN_EVENT_MTS db:s
@@ -6763,7 +6764,7 @@ static void slave_stop_workers(Relay_log_info *rli, bool *mts_inited) {
67636764
if (!rli->workers.empty()) {
67646765
for (int i = static_cast<int>(rli->workers.size()) - 1; i >= 0; i--) {
67656766
Slave_worker *w = rli->workers[i];
6766-
struct slave_job_item item = {nullptr, 0, 0};
6767+
struct slave_job_item item = {nullptr, 0, {'\0'}};
67676768
struct slave_job_item *job_item = &item;
67686769
mysql_mutex_lock(&w->jobs_lock);
67696770

sql/rpl_rli.cc

-18
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ Relay_log_info::Relay_log_info(bool is_slave_recovery,
140140
transaction_parser(mysql::binlog::event::Transaction_boundary_parser::
141141
TRX_BOUNDARY_PARSER_APPLIER),
142142
group_relay_log_pos(0),
143-
event_relay_log_number(0),
144143
event_relay_log_pos(0),
145144
group_source_log_seen_start_pos(false),
146145
group_source_log_start_pos(0),
@@ -2682,23 +2681,6 @@ ulong Relay_log_info::adapt_to_master_version_updown(ulong master_version,
26822681
return master_version;
26832682
}
26842683

2685-
void Relay_log_info::relay_log_number_to_name(uint number,
2686-
char name[FN_REFLEN + 1]) {
2687-
char *str = nullptr;
2688-
char relay_bin_channel[FN_REFLEN + 1];
2689-
const char *relay_log_basename_channel = add_channel_to_relay_log_name(
2690-
relay_bin_channel, FN_REFLEN + 1, relay_log_basename);
2691-
2692-
/* str points to closing null of relay log basename channel */
2693-
str = strmake(name, relay_log_basename_channel, FN_REFLEN + 1);
2694-
*str++ = '.';
2695-
sprintf(str, "%06u", number);
2696-
}
2697-
2698-
uint Relay_log_info::relay_log_name_to_number(const char *name) {
2699-
return static_cast<uint>(atoi(fn_ext(name) + 1));
2700-
}
2701-
27022684
bool is_mts_db_partitioned(Relay_log_info *rli) {
27032685
return (rli->current_mts_submode->get_type() == MTS_PARALLEL_TYPE_DB_NAME);
27042686
}

sql/rpl_rli.h

+1-20
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ typedef Prealloced_array<Slave_worker *, 4> Slave_worker_array;
8181

8282
typedef struct slave_job_item {
8383
Log_event *data;
84-
uint relay_number;
8584
my_off_t relay_pos;
85+
char event_relay_log_name[FN_REFLEN + 1];
8686
} Slave_job_item;
8787

8888
/**
@@ -699,8 +699,6 @@ class Relay_log_info : public Rpl_info {
699699
char group_relay_log_name[FN_REFLEN];
700700
ulonglong group_relay_log_pos;
701701
char event_relay_log_name[FN_REFLEN];
702-
/* The suffix number of relay log name */
703-
uint event_relay_log_number;
704702
ulonglong event_relay_log_pos;
705703
ulonglong future_event_relay_log_pos;
706704

@@ -1647,26 +1645,9 @@ class Relay_log_info : public Rpl_info {
16471645
inline void set_event_relay_log_name(const char *log_file_name) {
16481646
strmake(event_relay_log_name, log_file_name,
16491647
sizeof(event_relay_log_name) - 1);
1650-
set_event_relay_log_number(relay_log_name_to_number(log_file_name));
16511648
notify_relay_log_change();
16521649
}
16531650

1654-
uint get_event_relay_log_number() { return event_relay_log_number; }
1655-
void set_event_relay_log_number(uint number) {
1656-
event_relay_log_number = number;
1657-
}
1658-
1659-
/**
1660-
Given the extension number of the relay log, gets the full
1661-
relay log path. Currently used in Slave_worker::retry_transaction()
1662-
1663-
@param [in] number extension number of relay log
1664-
@param[in, out] name The full path of the relay log (per-channel)
1665-
to be read by the slave worker.
1666-
*/
1667-
void relay_log_number_to_name(uint number, char name[FN_REFLEN + 1]);
1668-
uint relay_log_name_to_number(const char *name);
1669-
16701651
void set_event_start_pos(my_off_t pos) { event_start_pos = pos; }
16711652
my_off_t get_event_start_pos() { return event_start_pos; }
16721653

0 commit comments

Comments
 (0)