168
168
/* if file does not exist */
169
169
if (access(fname,F_OK))
172
If someone removed the file from underneath our feet, just close
173
the old descriptor and re-create the old file
176
my_close(info_fd, MYF(MY_WME));
177
if ((info_fd = my_open(fname, O_CREAT|O_RDWR|O_BINARY, MYF(MY_WME))) < 0)
179
sql_print_error(_("Failed to create a new relay log info file "
180
"( file '%s', errno %d)"), fname, my_errno);
181
msg= current_thd->main_da.message();
184
if (init_io_cache(&rli->info_file, info_fd, IO_SIZE*2, READ_CACHE, 0L,0,
187
sql_print_error(_("Failed to create a cache on relay log info file '%s'"),
189
msg= current_thd->main_da.message();
193
/* Init relay log with first entry in the relay index file */
194
if (init_relay_log_pos(rli,NULL,BIN_LOG_HEADER_SIZE,0 /* no data lock */,
197
sql_print_error(_("Failed to open the relay log 'FIRST' (relay_log_pos 4)"));
200
rli->group_master_log_name[0]= 0;
201
rli->group_master_log_pos= 0;
202
rli->info_fd= info_fd;
171
/* Create a new file */
204
173
else // file exists
207
reinit_io_cache(&rli->info_file, READ_CACHE, 0L,0,0);
211
if ((info_fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0)
213
sql_print_error(_("Failed to open the existing relay log info "
214
"file '%s' (errno %d)"),
218
else if (init_io_cache(&rli->info_file, info_fd,
219
IO_SIZE*2, READ_CACHE, 0L, 0, MYF(MY_WME)))
221
sql_print_error(_("Failed to create a cache on relay log info "
229
my_close(info_fd, MYF(0));
231
rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
232
pthread_mutex_unlock(&rli->data_lock);
237
rli->info_fd = info_fd;
238
int32_t relay_log_pos, master_log_pos;
239
if (init_strvar_from_file(rli->group_relay_log_name,
240
sizeof(rli->group_relay_log_name),
241
&rli->info_file, "") ||
242
init_intvar_from_file(&relay_log_pos,
243
&rli->info_file, BIN_LOG_HEADER_SIZE) ||
244
init_strvar_from_file(rli->group_master_log_name,
245
sizeof(rli->group_master_log_name),
246
&rli->info_file, "") ||
247
init_intvar_from_file(&master_log_pos, &rli->info_file, 0))
249
msg="Error reading slave log configuration";
252
strmake(rli->event_relay_log_name,rli->group_relay_log_name,
253
sizeof(rli->event_relay_log_name)-1);
254
rli->group_relay_log_pos= rli->event_relay_log_pos= relay_log_pos;
255
rli->group_master_log_pos= master_log_pos;
257
if (init_relay_log_pos(rli,
258
rli->group_relay_log_name,
259
rli->group_relay_log_pos,
264
sql_print_error(_("Failed to open the relay log '%s' (relay_log_pos %s)"),
265
rli->group_relay_log_name,
266
llstr(rli->group_relay_log_pos, llbuf));
175
/* Open up fname here and pull out the relay.info data */
270
assert(rli->event_relay_log_pos >= BIN_LOG_HEADER_SIZE);
271
assert(my_b_tell(rli->cur_log) == rli->event_relay_log_pos);
274
179
Now change the cache from READ to WRITE - must do this
665
570
configuration which does nothing), then group_master_log_pos
666
571
will grow and group_master_log_name will stay "".
668
if (*group_master_log_name)
573
if (group_master_log_name.length())
670
char *basename= (group_master_log_name +
671
dirname_length(group_master_log_name));
575
const char *basename= (group_master_log_name.c_str() +
576
dirname_length(group_master_log_name.c_str()));
673
578
First compare the parts before the extension.
674
579
Find the dot in the master's log basename,
875
779
/* Save name of used relay log file */
876
strmake(rli->group_relay_log_name, rli->relay_log.get_log_fname(),
877
sizeof(rli->group_relay_log_name)-1);
878
strmake(rli->event_relay_log_name, rli->relay_log.get_log_fname(),
879
sizeof(rli->event_relay_log_name)-1);
780
rli->group_relay_log_name.assign(rli->relay_log.get_log_fname());
781
rli->event_relay_log_name.assign(rli->relay_log.get_log_fname());
880
782
rli->group_relay_log_pos= rli->event_relay_log_pos= BIN_LOG_HEADER_SIZE;
881
783
if (count_relay_log_space(rli))