~ubuntu-branches/ubuntu/wily/mysql-5.6/wily

« back to all changes in this revision

Viewing changes to sql/rpl_master.cc

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2015-04-16 20:07:10 UTC
  • mto: (1.3.9 vivid-proposed)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: package-import@ubuntu.com-20150416200710-pcrsa022082zj46k
Tags: upstream-5.6.24
ImportĀ upstreamĀ versionĀ 5.6.24

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
 
1
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
2
2
 
3
3
   This program is free software; you can redistribute it and/or modify
4
4
   it under the terms of the GNU General Public License as published by
860
860
  IO_CACHE log;
861
861
  File file = -1;
862
862
  String* packet = &thd->packet;
863
 
  int error;
 
863
  time_t last_event_sent_ts= time(0);
 
864
  bool time_for_hb_event= false;
 
865
  int error= 0;
864
866
  const char *errmsg = "Unknown error";
865
867
  char error_text[MAX_SLAVE_ERRMSG]; // to be send to slave via my_message()
866
868
  NET* net = &thd->net;
1240
1242
                                                         STRING_WITH_LEN(act)));
1241
1243
                    };);
1242
1244
    bool is_active_binlog= false;
1243
 
    while (!(error= Log_event::read_log_event(&log, packet, log_lock,
 
1245
    while (!thd->killed &&
 
1246
           !(error= Log_event::read_log_event(&log, packet, log_lock,
1244
1247
                                              current_checksum_alg,
1245
1248
                                              log_file_name,
1246
1249
                                              &is_active_binlog)))
1247
1250
    {
 
1251
      DBUG_EXECUTE_IF("hold_dump_thread_inside_inner_loop",
 
1252
                    {
 
1253
                      const char act[]= "now "
 
1254
                                        "signal signal_inside_inner_loop "
 
1255
                                        "wait_for signal_continue";
 
1256
                      DBUG_ASSERT(!debug_sync_set_action(current_thd,
 
1257
                                                         STRING_WITH_LEN(act)));
 
1258
                      DBUG_ASSERT(thd->killed);
 
1259
                    };);
1248
1260
      time_t created;
1249
1261
      DBUG_PRINT("info", ("read_log_event returned 0 on line %d", __LINE__));
1250
1262
#ifndef DBUG_OFF
1430
1442
      {
1431
1443
        p_last_skip_coord->pos= p_coord->pos;
1432
1444
        strcpy(p_last_skip_coord->file_name, p_coord->file_name);
 
1445
        /*
 
1446
          If we have not send any event from past 'heartbeat_period' time
 
1447
          period, then it is time to send a packet before skipping this group.
 
1448
         */
 
1449
        DBUG_EXECUTE_IF("inject_2sec_sleep_when_skipping_an_event",
 
1450
                        {
 
1451
                          my_sleep(2000000);
 
1452
                        });
 
1453
        time_t now= time(0);
 
1454
        DBUG_ASSERT(now >= last_event_sent_ts);
 
1455
        time_for_hb_event= ((ulonglong)(now - last_event_sent_ts) >=
 
1456
                            (ulonglong)(heartbeat_period/1000000000UL));
1433
1457
      }
1434
1458
 
1435
 
      if (!skip_group && last_skip_group
1436
 
          && event_type != FORMAT_DESCRIPTION_EVENT)
 
1459
      if ((!skip_group && last_skip_group
 
1460
           && event_type != FORMAT_DESCRIPTION_EVENT) || time_for_hb_event)
1437
1461
      {
1438
1462
        /*
1439
1463
          Dump thread is ready to send it's first transaction after
1440
 
          one or more skipped transactions. Send a heart beat event
 
1464
          one or more skipped transactions or dump thread did not
 
1465
          send any event from past 'heartbeat_period' time frame
 
1466
          (busy skipping gtid groups). Send a heart beat event
1441
1467
          to update slave IO thread coordinates before that happens.
1442
1468
 
1443
1469
          Notice that for a new binary log file, FORMAT_DESCRIPTION_EVENT
1452
1478
        {
1453
1479
          GOTO_ERR;
1454
1480
        }
1455
 
      }
1456
 
 
1457
 
      /* save this flag for next iteration */
1458
 
      last_skip_group= skip_group;
1459
 
 
1460
 
      if (skip_group == false && my_net_write(net, (uchar*) packet->ptr(), packet->length()))
1461
 
      {
1462
 
        errmsg = "Failed on my_net_write()";
1463
 
        my_errno= ER_UNKNOWN_ERROR;
1464
 
        GOTO_ERR;
1465
 
      }
1466
 
 
 
1481
        last_event_sent_ts= time(0);
 
1482
        last_skip_group= time_for_hb_event= false;
 
1483
      }
 
1484
      else
 
1485
      {
 
1486
        last_skip_group= skip_group;
 
1487
      }
 
1488
 
 
1489
      if (skip_group == false)
 
1490
      {
 
1491
        if (my_net_write(net, (uchar*) packet->ptr(), packet->length()))
 
1492
        {
 
1493
          errmsg = "Failed on my_net_write()";
 
1494
          my_errno= ER_UNKNOWN_ERROR;
 
1495
          GOTO_ERR;
 
1496
        }
 
1497
        last_event_sent_ts= time(0);
 
1498
      }
1467
1499
 
1468
1500
      DBUG_EXECUTE_IF("dump_thread_wait_before_send_xid",
1469
1501
                      {
1665
1697
            */
1666
1698
            if (skip_group)
1667
1699
            {
 
1700
              /*
 
1701
                TODO: Number of HB events sent from here can be reduced
 
1702
               by checking whehter it is time to send a HB event or not.
 
1703
               (i.e., using the flag time_for_hb_event)
 
1704
              */
1668
1705
              if (send_last_skip_group_heartbeat(thd, net, packet,
1669
1706
                                                 p_coord, &ev_offset,
1670
1707
                                                 current_checksum_alg, &errmsg,
1821
1858
             my_errno= ER_UNKNOWN_ERROR;
1822
1859
             GOTO_ERR;
1823
1860
            }
 
1861
            last_event_sent_ts= time(0);
1824
1862
 
1825
1863
            if (event_type == LOAD_EVENT)
1826
1864
            {
2048
2086
      sql_print_information("While initializing dump thread for slave with "
2049
2087
                            "UUID <%s>, found a zombie dump thread with "
2050
2088
                            "the same UUID. Master is killing the zombie dump "
2051
 
                            "thread.", slave_uuid->c_ptr());
 
2089
                            "thread(%lu).", slave_uuid->c_ptr(), tmp->thread_id);
2052
2090
    tmp->awake(THD::KILL_QUERY);
2053
2091
    mysql_mutex_unlock(&tmp->LOCK_thd_data);
2054
2092
  }