@@ -2193,10 +2193,8 @@ static int init_binlog_sender(binlog_send_info *info,
2193
2193
/* *
2194
2194
* send format descriptor event for one binlog file
2195
2195
*/
2196
- static int send_format_descriptor_event (binlog_send_info *info,
2197
- IO_CACHE *log,
2198
- LOG_INFO *linfo,
2199
- my_off_t start_pos)
2196
+ static int send_format_descriptor_event (binlog_send_info *info, IO_CACHE *log,
2197
+ LOG_INFO *linfo, my_off_t start_pos)
2200
2198
{
2201
2199
int error;
2202
2200
ulong ev_offset;
@@ -2220,145 +2218,139 @@ static int send_format_descriptor_event(binlog_send_info *info,
2220
2218
return 1 ;
2221
2219
}
2222
2220
2223
- do
2221
+ /* reset transmit packet for the event read from binary log file */
2222
+ if (reset_transmit_packet (info, info->flags , &ev_offset, &info->errmsg ))
2223
+ return 1 ;
2224
+
2225
+ /*
2226
+ Try to find a Format_description_log_event at the beginning of
2227
+ the binlog
2228
+ */
2229
+ info->last_pos = my_b_tell (log);
2230
+ error= Log_event::read_log_event (log, packet,
2231
+ opt_master_verify_checksum
2232
+ ? info->current_checksum_alg : 0 );
2233
+ linfo->pos = my_b_tell (log);
2234
+
2235
+ if (error)
2224
2236
{
2225
- /* reset transmit packet for the event read from binary log file */
2226
- if ( reset_transmit_packet (info, info-> flags , &ev_offset, &info-> errmsg ))
2227
- break ;
2237
+ set_read_error (info, error);
2238
+ return 1 ;
2239
+ }
2228
2240
2229
- /*
2230
- Try to find a Format_description_log_event at the beginning of
2231
- the binlog
2232
- */
2233
- info->last_pos = my_b_tell (log);
2234
- error= Log_event::read_log_event (log, packet,
2235
- opt_master_verify_checksum
2236
- ? info->current_checksum_alg : 0 );
2237
- linfo->pos = my_b_tell (log);
2241
+ event_type= (Log_event_type)((uchar)(*packet)[LOG_EVENT_OFFSET+ev_offset]);
2238
2242
2239
- if (error)
2240
- {
2241
- set_read_error (info, error);
2242
- break ;
2243
- }
2243
+ /*
2244
+ The packet has offsets equal to the normal offsets in a
2245
+ binlog event + ev_offset (the first ev_offset characters are
2246
+ the header (default \0)).
2247
+ */
2248
+ DBUG_PRINT (" info" ,
2249
+ (" Looked for a Format_description_log_event, "
2250
+ " found event type %d" , (int )event_type));
2244
2251
2245
- event_type= (Log_event_type)((uchar)(*packet)[LOG_EVENT_OFFSET+ev_offset]);
2252
+ if (event_type != FORMAT_DESCRIPTION_EVENT)
2253
+ {
2254
+ info->error = ER_MASTER_FATAL_ERROR_READING_BINLOG;
2255
+ info->errmsg = " Failed to find format descriptor event in start of binlog" ;
2256
+ sql_print_warning (" Failed to find format descriptor event in "
2257
+ " start of binlog: %s" ,
2258
+ info->log_file_name );
2259
+ return 1 ;
2260
+ }
2246
2261
2247
- /*
2248
- The packet has offsets equal to the normal offsets in a
2249
- binlog event + ev_offset (the first ev_offset characters are
2250
- the header (default \0)).
2251
- */
2252
- DBUG_PRINT (" info" ,
2253
- (" Looked for a Format_description_log_event, "
2254
- " found event type %d" , (int )event_type));
2262
+ info->current_checksum_alg = get_checksum_alg (packet->ptr () + ev_offset,
2263
+ packet->length () - ev_offset);
2255
2264
2256
- if (event_type != FORMAT_DESCRIPTION_EVENT)
2257
- {
2258
- info->error = ER_MASTER_FATAL_ERROR_READING_BINLOG;
2259
- info->errmsg = " Failed to find format descriptor event in start of binlog" ;
2260
- sql_print_warning (" Failed to find format descriptor event in "
2261
- " start of binlog: %s" ,
2262
- info->log_file_name );
2263
- break ;
2264
- }
2265
+ DBUG_ASSERT (info->current_checksum_alg == BINLOG_CHECKSUM_ALG_OFF ||
2266
+ info->current_checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF ||
2267
+ info->current_checksum_alg == BINLOG_CHECKSUM_ALG_CRC32);
2265
2268
2266
- info->current_checksum_alg = get_checksum_alg (packet->ptr () + ev_offset,
2267
- packet->length () - ev_offset);
2269
+ if (!is_slave_checksum_aware (thd) &&
2270
+ info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
2271
+ info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
2272
+ {
2273
+ info->error = ER_MASTER_FATAL_ERROR_READING_BINLOG;
2274
+ info->errmsg = " Slave can not handle replication events with the "
2275
+ " checksum that master is configured to log" ;
2276
+ sql_print_warning (" Master is configured to log replication events "
2277
+ " with checksum, but will not send such events to "
2278
+ " slaves that cannot process them" );
2279
+ return 1 ;
2280
+ }
2268
2281
2269
- DBUG_ASSERT (info->current_checksum_alg == BINLOG_CHECKSUM_ALG_OFF ||
2270
- info->current_checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF ||
2271
- info->current_checksum_alg == BINLOG_CHECKSUM_ALG_CRC32);
2282
+ Format_description_log_event *tmp;
2283
+ if (!(tmp= new Format_description_log_event (packet->ptr ()+ev_offset,
2284
+ packet->length ()-ev_offset,
2285
+ info->fdev )))
2286
+ {
2287
+ info->error = ER_MASTER_FATAL_ERROR_READING_BINLOG;
2288
+ info->errmsg = " Corrupt Format_description event found "
2289
+ " or out-of-memory" ;
2290
+ return 1 ;
2291
+ }
2292
+ delete info->fdev ;
2293
+ info->fdev = tmp;
2272
2294
2273
- if (!is_slave_checksum_aware (thd) &&
2274
- info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
2275
- info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
2276
- {
2277
- info->error = ER_MASTER_FATAL_ERROR_READING_BINLOG;
2278
- info->errmsg = " Slave can not handle replication events with the "
2279
- " checksum that master is configured to log" ;
2280
- sql_print_warning (" Master is configured to log replication events "
2281
- " with checksum, but will not send such events to "
2282
- " slaves that cannot process them" );
2283
- break ;
2284
- }
2295
+ (*packet)[FLAGS_OFFSET+ev_offset] &= ~LOG_EVENT_BINLOG_IN_USE_F;
2285
2296
2286
- Format_description_log_event *tmp;
2287
- if (!(tmp= new Format_description_log_event (packet->ptr ()+ev_offset,
2288
- packet->length ()-ev_offset,
2289
- info->fdev )))
2290
- {
2291
- info->error = ER_MASTER_FATAL_ERROR_READING_BINLOG;
2292
- info->errmsg = " Corrupt Format_description event found "
2293
- " or out-of-memory" ;
2294
- break ;
2295
- }
2296
- delete info->fdev ;
2297
- info->fdev = tmp;
2297
+ if (info->clear_initial_log_pos )
2298
+ {
2299
+ info->clear_initial_log_pos = false ;
2300
+ /*
2301
+ mark that this event with "log_pos=0", so the slave
2302
+ should not increment master's binlog position
2303
+ (rli->group_master_log_pos)
2304
+ */
2305
+ int4store ((char *) packet->ptr ()+LOG_POS_OFFSET+ev_offset, (ulong) 0 );
2298
2306
2299
- (*packet)[FLAGS_OFFSET+ev_offset] &= ~LOG_EVENT_BINLOG_IN_USE_F;
2307
+ /*
2308
+ if reconnect master sends FD event with `created' as 0
2309
+ to avoid destroying temp tables.
2310
+ */
2311
+ int4store ((char *) packet->ptr ()+LOG_EVENT_MINIMAL_HEADER_LEN+
2312
+ ST_CREATED_OFFSET+ev_offset, (ulong) 0 );
2300
2313
2301
- if (info->clear_initial_log_pos )
2314
+ /* fix the checksum due to latest changes in header */
2315
+ if (info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
2316
+ info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
2317
+ fix_checksum (packet, ev_offset);
2318
+ }
2319
+ else if (info->using_gtid_state )
2320
+ {
2321
+ /*
2322
+ If this event has the field `created' set, then it will cause the
2323
+ slave to delete all active temporary tables. This must not happen
2324
+ if the slave received any later GTIDs in a previous connect, as
2325
+ those GTIDs might have created new temporary tables that are still
2326
+ needed.
2327
+
2328
+ So here, we check if the starting GTID position was already
2329
+ reached before this format description event. If not, we clear the
2330
+ `created' flag to preserve temporary tables on the slave. (If the
2331
+ slave connects at a position past this event, it means that it
2332
+ already received and handled it in a previous connect).
2333
+ */
2334
+ if (!info->gtid_state .is_pos_reached ())
2302
2335
{
2303
- info->clear_initial_log_pos = false ;
2304
- /*
2305
- mark that this event with "log_pos=0", so the slave
2306
- should not increment master's binlog position
2307
- (rli->group_master_log_pos)
2308
- */
2309
- int4store ((char *) packet->ptr ()+LOG_POS_OFFSET+ev_offset, (ulong) 0 );
2310
-
2311
- /*
2312
- if reconnect master sends FD event with `created' as 0
2313
- to avoid destroying temp tables.
2314
- */
2315
2336
int4store ((char *) packet->ptr ()+LOG_EVENT_MINIMAL_HEADER_LEN+
2316
2337
ST_CREATED_OFFSET+ev_offset, (ulong) 0 );
2317
-
2318
- /* fix the checksum due to latest changes in header */
2319
2338
if (info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
2320
- info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
2339
+ info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
2321
2340
fix_checksum (packet, ev_offset);
2322
2341
}
2323
- else if (info->using_gtid_state )
2324
- {
2325
- /*
2326
- If this event has the field `created' set, then it will cause the
2327
- slave to delete all active temporary tables. This must not happen
2328
- if the slave received any later GTIDs in a previous connect, as
2329
- those GTIDs might have created new temporary tables that are still
2330
- needed.
2331
-
2332
- So here, we check if the starting GTID position was already
2333
- reached before this format description event. If not, we clear the
2334
- `created' flag to preserve temporary tables on the slave. (If the
2335
- slave connects at a position past this event, it means that it
2336
- already received and handled it in a previous connect).
2337
- */
2338
- if (!info->gtid_state .is_pos_reached ())
2339
- {
2340
- int4store ((char *) packet->ptr ()+LOG_EVENT_MINIMAL_HEADER_LEN+
2341
- ST_CREATED_OFFSET+ev_offset, (ulong) 0 );
2342
- if (info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
2343
- info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
2344
- fix_checksum (packet, ev_offset);
2345
- }
2346
- }
2347
-
2348
- /* send it */
2349
- if (my_net_write (info->net , (uchar*) packet->ptr (), packet->length ()))
2350
- {
2351
- info->errmsg = " Failed on my_net_write()" ;
2352
- info->error = ER_UNKNOWN_ERROR;
2353
- break ;
2354
- }
2355
-
2356
- /* * all done */
2357
- return 0 ;
2342
+ }
2358
2343
2359
- } while (false );
2344
+ /* send it */
2345
+ if (my_net_write (info->net , (uchar*) packet->ptr (), packet->length ()))
2346
+ {
2347
+ info->errmsg = " Failed on my_net_write()" ;
2348
+ info->error = ER_UNKNOWN_ERROR;
2349
+ return 1 ;
2350
+ }
2360
2351
2361
- return 1 ;
2352
+ /* * all done */
2353
+ return 0 ;
2362
2354
}
2363
2355
2364
2356
static bool should_stop (binlog_send_info *info)
@@ -2545,9 +2537,7 @@ static my_off_t get_binlog_end_pos(binlog_send_info *info,
2545
2537
* return 0 - OK
2546
2538
* else NOK
2547
2539
*/
2548
- static int send_events (binlog_send_info *info,
2549
- IO_CACHE* log,
2550
- LOG_INFO* linfo,
2540
+ static int send_events (binlog_send_info *info, IO_CACHE* log, LOG_INFO* linfo,
2551
2541
my_off_t end_pos)
2552
2542
{
2553
2543
int error;
@@ -2575,7 +2565,8 @@ static int send_events(binlog_send_info *info,
2575
2565
2576
2566
if (error)
2577
2567
{
2578
- goto read_err;
2568
+ set_read_error (info, error);
2569
+ return 1 ;
2579
2570
}
2580
2571
2581
2572
Log_event_type event_type=
@@ -2661,11 +2652,6 @@ static int send_events(binlog_send_info *info,
2661
2652
}
2662
2653
2663
2654
return 0 ;
2664
-
2665
- read_err:
2666
- set_read_error (info, error);
2667
-
2668
- return 1 ;
2669
2655
}
2670
2656
2671
2657
/* *
0 commit comments