~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to sql/sql_repl.cc

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2006 MySQL AB & Sasha
 
1
/*
 
2
   Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
2
3
 
3
4
   This program is free software; you can redistribute it and/or modify
4
5
   it under the terms of the GNU General Public License as published by
11
12
 
12
13
   You should have received a copy of the GNU General Public License
13
14
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
16
*/
15
17
 
16
18
#include "mysql_priv.h"
17
19
#ifdef HAVE_REPLICATION
21
23
#include "log_event.h"
22
24
#include "rpl_filter.h"
23
25
#include <my_dir.h>
 
26
#include "debug_sync.h"
24
27
 
25
28
int max_binlog_dump_events = 0; // unlimited
26
29
my_bool opt_sporadic_binlog_dump_fail = 0;
218
221
    if ((linfo = tmp->current_linfo))
219
222
    {
220
223
      pthread_mutex_lock(&linfo->lock);
221
 
      result = !bcmp((uchar*) log_name, (uchar*) linfo->log_file_name,
222
 
                     log_name_len);
 
224
      result = !memcmp(log_name, linfo->log_file_name, log_name_len);
223
225
      pthread_mutex_unlock(&linfo->lock);
224
226
      if (result)
225
227
        break;
357
359
#ifndef DBUG_OFF
358
360
  int left_events = max_binlog_dump_events;
359
361
#endif
 
362
  int old_max_allowed_packet= thd->variables.max_allowed_packet;
360
363
  DBUG_ENTER("mysql_binlog_send");
361
364
  DBUG_PRINT("enter",("log_ident: '%s'  pos: %ld", log_ident, (long) pos));
362
365
 
544
547
 
545
548
  while (!net->error && net->vio != 0 && !thd->killed)
546
549
  {
 
550
    my_off_t prev_pos= pos;
547
551
    while (!(error = Log_event::read_log_event(&log, packet, log_lock)))
548
552
    {
 
553
      prev_pos= my_b_tell(&log);
549
554
#ifndef DBUG_OFF
550
555
      if (max_binlog_dump_events && !left_events--)
551
556
      {
556
561
      }
557
562
#endif
558
563
 
 
564
      DBUG_EXECUTE_IF("dump_thread_wait_before_send_xid",
 
565
                      {
 
566
                        if ((*packet)[EVENT_TYPE_OFFSET+1] == XID_EVENT)
 
567
                        {
 
568
                          net_flush(net);
 
569
                          const char act[]=
 
570
                            "now "
 
571
                            "wait_for signal.continue";
 
572
                          DBUG_ASSERT(opt_debug_sync_timeout > 0);
 
573
                          DBUG_ASSERT(!debug_sync_set_action(current_thd,
 
574
                                                             STRING_WITH_LEN(act)));
 
575
                        }
 
576
                      });
 
577
 
559
578
      if ((*packet)[EVENT_TYPE_OFFSET+1] == FORMAT_DESCRIPTION_EVENT)
560
579
      {
561
580
        binlog_can_be_corrupted= test((*packet)[FLAGS_OFFSET+1] &
572
591
        goto err;
573
592
      }
574
593
 
 
594
      DBUG_EXECUTE_IF("dump_thread_wait_before_send_xid",
 
595
                      {
 
596
                        if ((*packet)[EVENT_TYPE_OFFSET+1] == XID_EVENT)
 
597
                        {
 
598
                          net_flush(net);
 
599
                        }
 
600
                      });
 
601
 
575
602
      DBUG_PRINT("info", ("log event code %d",
576
603
                          (*packet)[LOG_EVENT_OFFSET+1] ));
577
604
      if ((*packet)[LOG_EVENT_OFFSET+1] == LOAD_EVENT)
590
617
      here we were reading binlog that was not closed properly (as a result
591
618
      of a crash ?). treat any corruption as EOF
592
619
    */
593
 
    if (binlog_can_be_corrupted && error != LOG_READ_MEM)
 
620
    if (binlog_can_be_corrupted &&
 
621
        error != LOG_READ_MEM && error != LOG_READ_EOF)
 
622
    {
 
623
      my_b_seek(&log, prev_pos);
594
624
      error=LOG_READ_EOF;
 
625
    }
 
626
 
595
627
    /*
596
628
      TODO: now that we are logging the offset, check to make sure
597
629
      the recorded offset and the actual match.
762
794
  pthread_mutex_lock(&LOCK_thread_count);
763
795
  thd->current_linfo = 0;
764
796
  pthread_mutex_unlock(&LOCK_thread_count);
 
797
  thd->variables.max_allowed_packet= old_max_allowed_packet;
765
798
  DBUG_VOID_RETURN;
766
799
 
767
800
err:
779
812
  pthread_mutex_unlock(&LOCK_thread_count);
780
813
  if (file >= 0)
781
814
    (void) my_close(file, MYF(MY_WME));
 
815
  thd->variables.max_allowed_packet= old_max_allowed_packet;
782
816
 
783
817
  my_message(my_errno, errmsg, MYF(0));
784
818
  DBUG_VOID_RETURN;
1169
1203
  /*
1170
1204
    Before processing the command, save the previous state.
1171
1205
  */
1172
 
  char *pos;
1173
 
  pos= strmake(saved_host, mi->host, HOSTNAME_LENGTH);
1174
 
  pos= '\0';
 
1206
  strmake(saved_host, mi->host, HOSTNAME_LENGTH);
1175
1207
  saved_port= mi->port;
1176
 
  pos= strmake(saved_log_name, mi->master_log_name, FN_REFLEN - 1);
1177
 
  pos= '\0';
 
1208
  strmake(saved_log_name, mi->master_log_name, FN_REFLEN - 1);
1178
1209
  saved_log_pos= mi->master_log_pos;
1179
1210
 
1180
1211
  /*
1422
1453
  bool ret = TRUE;
1423
1454
  IO_CACHE log;
1424
1455
  File file = -1;
 
1456
  int old_max_allowed_packet= thd->variables.max_allowed_packet;
1425
1457
  DBUG_ENTER("mysql_show_binlog_events");
1426
1458
 
1427
1459
  Log_event::init_show_field_list(&field_list);
1560
1592
  pthread_mutex_lock(&LOCK_thread_count);
1561
1593
  thd->current_linfo = 0;
1562
1594
  pthread_mutex_unlock(&LOCK_thread_count);
 
1595
  thd->variables.max_allowed_packet= old_max_allowed_packet;
1563
1596
  DBUG_RETURN(ret);
1564
1597
}
1565
1598