forked from bluethinking/InnoSQL
-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathreplication_filename_position_crash.patch
More file actions
107 lines (103 loc) · 4.19 KB
/
replication_filename_position_crash.patch
File metadata and controls
107 lines (103 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Index: sql/sql_repl.cc
===================================================================
--- sql/sql_repl.cc (revision 318)
+++ sql/sql_repl.cc (working copy)
@@ -447,8 +447,7 @@
String* packet = &thd->packet;
int error;
const char *errmsg = "Unknown error";
- const char *fmt= "%s; the last event was read from '%s' at %s, the last byte read was read from '%s' at %s.";
- char llbuff1[22], llbuff2[22];
+ char llbuff0[22], llbuff1[22], llbuff2[22];
char error_text[MAX_SLAVE_ERRMSG]; // to be send to slave via my_message()
NET* net = &thd->net;
mysql_mutex_t *log_lock;
@@ -468,16 +467,15 @@
*/
ulonglong heartbeat_period= get_heartbeat_period(thd);
struct timespec heartbeat_buf;
- struct event_coordinates coord_buf;
+ const struct event_coordinates start_coord = { log_ident, pos },
+ *p_start_coord = &start_coord;
+ struct event_coordinates coord_buf={ log_file_name, BIN_LOG_HEADER_SIZE };
struct timespec *heartbeat_ts= NULL;
- struct event_coordinates *coord= NULL;
+ struct event_coordinates *coord= &coord_buf;
if (heartbeat_period != LL(0))
{
heartbeat_ts= &heartbeat_buf;
set_timespec_nsec(*heartbeat_ts, 0);
- coord= &coord_buf;
- coord->file_name= log_file_name; // initialization basing on what slave remembers
- coord->pos= pos;
}
sql_print_information("Start binlog_dump to slave_server(%d), pos(%s, %lu)",
thd->server_id, log_ident, (ulong)pos);
@@ -597,6 +595,7 @@
mysql_bin_log, and it's already inited, and it will be destroyed
only at shutdown).
*/
+ coord->pos=pos;
log_lock= mysql_bin_log.get_log_lock();
log_cond= mysql_bin_log.get_log_cond();
if (pos > BIN_LOG_HEADER_SIZE)
@@ -694,8 +693,7 @@
/*
log's filename does not change while it's active
*/
- if (coord)
- coord->pos= uint4korr(packet->ptr() + ev_offset + LOG_POS_OFFSET);
+ coord->pos= uint4korr(packet->ptr() + ev_offset + LOG_POS_OFFSET);
event_type= (Log_event_type)((*packet)[LOG_EVENT_OFFSET+ev_offset]);
DBUG_EXECUTE_IF("dump_thread_wait_before_send_xid",
@@ -851,8 +849,7 @@
/* we read successfully, so we'll need to send it to the slave */
mysql_mutex_unlock(log_lock);
read_packet = 1;
- if (coord)
- coord->pos= uint4korr(packet->ptr() + ev_offset + LOG_POS_OFFSET);
+ coord->pos= uint4korr(packet->ptr() + ev_offset + LOG_POS_OFFSET);
event_type= (Log_event_type)((*packet)[LOG_EVENT_OFFSET+ev_offset]);
break;
@@ -874,16 +871,16 @@
signal_cnt= mysql_bin_log.signal_cnt;
do
{
- if (coord)
+ if (heartbeat_period != 0)
{
- DBUG_ASSERT(heartbeat_ts && heartbeat_period != 0);
+ DBUG_ASSERT(heartbeat_ts);
set_timespec_nsec(*heartbeat_ts, heartbeat_period);
}
thd->enter_cond(log_cond, log_lock,
"Master has sent all binlog to slave; "
"waiting for binlog to be updated");
ret= mysql_bin_log.wait_for_update_bin_log(thd, heartbeat_ts);
- DBUG_ASSERT(ret == 0 || (heartbeat_period != 0 && coord != NULL));
+ DBUG_ASSERT(ret == 0 || (heartbeat_period != 0));
if (ret == ETIMEDOUT || ret == ETIME)
{
#ifndef DBUG_OFF
@@ -1012,8 +1009,7 @@
goto err;
}
- if (coord)
- coord->file_name= log_file_name; // reset to the next
+ coord->file_name= log_file_name; // reset to the next
}
}
@@ -1038,8 +1034,12 @@
detailing the fatal error message with coordinates
of the last position read.
*/
+ const char *fmt= "%s; the start event position from '%s' at %s, the last event was read from '%s' at %s, the last byte read was read from '%s' at %s.";
my_snprintf(error_text, sizeof(error_text), fmt, errmsg,
- coord->file_name, (llstr(coord->pos, llbuff1), llbuff1),
+ p_start_coord->file_name,
+ (llstr(p_start_coord->pos, llbuff0), llbuff0),
+ coord->file_name,
+ (llstr(coord->pos, llbuff1), llbuff1),
log_file_name, (llstr(my_b_tell(&log), llbuff2), llbuff2));
}
else