List:Internals« Previous MessageNext Message »
From:sasha Date:June 24 2001 1:37am
Subject:bk commit into 3.23 tree
View as plain text  
Below is the list of changes that have just been pushed into main
3.23. repository. For information on how to access the repository
see http://www.mysql.com/doc/I/n/Installing_source_tree.html
>>>>>>> BitKeeper/tmp/post-commit_sasha@stripped

ChangeSet@stripped, 2001-06-23 19:37:24-06:00, sasha@stripped
  show master forced rotate info in SHOW BINLOG EVENTS
  mark a master-forced rotate with a special flag

  mysql-test/r/rpl000014.result
    1.9 01/06/23 19:37:23 sasha@stripped +8 -8
    updated result

  mysql-test/r/rpl000015.result
    1.8 01/06/23 19:37:23 sasha@stripped +8 -8
    updated result

  mysql-test/r/rpl000016.result
    1.12 01/06/23 19:37:23 sasha@stripped +6 -6
    updated result

  mysql-test/r/rpl_log.result
    1.3 01/06/23 19:37:23 sasha@stripped +9 -1
    updated result

  mysql-test/t/rpl000017-slave.sh
    1.3 01/06/23 19:37:23 sasha@stripped +1 -0
    fix for change in master.info format

  mysql-test/t/rpl_log.test
    1.3 01/06/23 19:37:23 sasha@stripped +5 -0
    test for correct last_log_seq in show slave status

  sql/log.cc
    1.61 01/06/23 19:37:23 sasha@stripped +7 -0
    mark a master-forced rotate with a special flag

  sql/log_event.cc
    1.43 01/06/23 19:37:23 sasha@stripped +5 -1
    show master forced rotate info in SHOW BINLOG EVENTS

  sql/log_event.h
    1.45 01/06/23 19:37:23 sasha@stripped +1 -0
    master forced rotation flag

  sql/slave.cc
    1.112 01/06/23 19:37:23 sasha@stripped +27 -8
    keep trace of last log sequences in MASTER_INFO
    do not rotate on slave, if the rotation on master was forced by its master

  sql/slave.h
    1.18 01/06/23 19:37:23 sasha@stripped +2 -1
    keep track of last log sequence number in MASTER_INFO

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	sasha
# Host:	mysql.sashanet.com
# Root:	/home/sasha/src/bk/mysql-4.0

--- 1.60/sql/log.cc	Fri Jun 22 08:35:17 2001
+++ 1.61/sql/log.cc	Sat Jun 23 19:37:23 2001
@@ -534,7 +534,14 @@
 	to change base names at some point.
       */
       Rotate_log_event r(new_name+dirname_length(new_name));
+      THD* thd = current_thd;
       r.set_log_seq(0, this);
+      // this log rotation could have been initiated by a master of
+      // the slave running with log-bin
+      // we set the flag on rotate event to prevent inifinite log rotation
+      // loop
+      if(thd && slave_thd && thd == slave_thd)
+	r.flags |= LOG_EVENT_FORCED_ROTATE_F;
       r.write(&log_file);
       VOID(pthread_cond_broadcast(&COND_binlog_update));
     }

--- 1.42/sql/log_event.cc	Fri Jun 22 08:35:17 2001
+++ 1.43/sql/log_event.cc	Sat Jun 23 19:37:23 2001
@@ -189,7 +189,11 @@
 
 void Rotate_log_event::pack_info(String* packet)
 {
-  net_store_data(packet, new_log_ident, ident_len);
+  String tmp;
+  tmp.append(new_log_ident, ident_len);
+  if(flags & LOG_EVENT_FORCED_ROTATE_F)
+    tmp.append("; forced by master");
+  net_store_data(packet, tmp.ptr(), tmp.length());
 }
 
 void Intvar_log_event::pack_info(String* packet)

--- 1.44/sql/log_event.h	Thu Jun 21 13:19:23 2001
+++ 1.45/sql/log_event.h	Sat Jun 23 19:37:23 2001
@@ -107,6 +107,7 @@
 #define BINLOG_MAGIC        "\xfe\x62\x69\x6e"
 
 #define LOG_EVENT_TIME_F           0x1
+#define LOG_EVENT_FORCED_ROTATE_F  0x2
 
 enum Log_event_type { START_EVENT = 1, QUERY_EVENT =2,
 		      STOP_EVENT=3, ROTATE_EVENT = 4, INTVAR_EVENT=5,

--- 1.111/sql/slave.cc	Fri Jun 22 08:35:17 2001
+++ 1.112/sql/slave.cc	Sat Jun 23 19:37:23 2001
@@ -545,7 +545,9 @@
 			     master_password) ||
        init_intvar_from_file((int*)&mi->port, &mi->file, master_port) ||
        init_intvar_from_file((int*)&mi->connect_retry, &mi->file,
-			     master_connect_retry))
+			     master_connect_retry) ||
+       init_intvar_from_file((int*)&mi->last_log_seq, &mi->file, 0)
+       )
     {
       msg="Error reading master configuration";
       goto error;
@@ -625,10 +627,12 @@
   field_list.push_back(new Item_empty_string("Last_errno", 4));
   field_list.push_back(new Item_empty_string("Last_error", 20));
   field_list.push_back(new Item_empty_string("Skip_counter", 12));
+  field_list.push_back(new Item_empty_string("Last_log_seq", 12));
   if(send_fields(thd, field_list, 1))
     DBUG_RETURN(-1);
 
   String* packet = &thd->packet;
+  uint32 last_log_seq;
   packet->length(0);
   
   pthread_mutex_lock(&glob_mi.lock);
@@ -637,7 +641,8 @@
   net_store_data(packet, (uint32) glob_mi.port);
   net_store_data(packet, (uint32) glob_mi.connect_retry);
   net_store_data(packet, glob_mi.log_file_name);
-  net_store_data(packet, (uint32) glob_mi.pos);	// QQ: Should be fixed
+  net_store_data(packet, (longlong) glob_mi.pos);
+  last_log_seq = glob_mi.last_log_seq;
   pthread_mutex_unlock(&glob_mi.lock);
   pthread_mutex_lock(&LOCK_slave);
   net_store_data(packet, slave_running ? "Yes":"No");
@@ -647,6 +652,7 @@
   net_store_data(packet, (uint32)last_slave_errno);
   net_store_data(packet, last_slave_error);
   net_store_data(packet, slave_skip_counter);
+  net_store_data(packet, last_log_seq);
   
   if (my_net_write(&thd->net, (char*)thd->packet.ptr(), packet->length()))
     DBUG_RETURN(-1);
@@ -659,11 +665,13 @@
 {
   IO_CACHE* file = &mi->file;
   char lbuf[22];
+  char lbuf1[22];
   
   my_b_seek(file, 0L);
-  my_b_printf(file, "%s\n%s\n%s\n%s\n%s\n%d\n%d\n",
+  my_b_printf(file, "%s\n%s\n%s\n%s\n%s\n%d\n%d\n%d\n",
 	      mi->log_file_name, llstr(mi->pos, lbuf), mi->host, mi->user,
-	      mi->password, mi->port, mi->connect_retry);
+	      mi->password, mi->port, mi->connect_retry,
+	      llstr(mi->last_log_seq, lbuf1));
   flush_io_cache(file);
   return 0;
 }
@@ -1011,9 +1019,9 @@
 	return 1;
       }
       free_root(&thd->mem_root,0);
+      mi->last_log_seq = ev->log_seq;
       delete ev;
       thd->log_seq = 0;
-
       mi->inc_pos(event_len);
       flush_master_info(mi);
       break;
@@ -1027,8 +1035,11 @@
 	mysql_bin_log.write(sev);
       }
 
+      mi->last_log_seq = ev->log_seq;
       delete ev;
       thd->log_seq = 0;
+      mi->inc_pos(event_len);
+      flush_master_info(mi);
       break;
     }
 	  
@@ -1139,6 +1150,7 @@
 	return 1;
       }
       
+      mi->last_log_seq = ev->log_seq;
       delete ev;
       thd->log_seq = 0;
       free_root(&thd->mem_root,0);
@@ -1158,6 +1170,7 @@
     case START_EVENT:
       close_temporary_tables(thd);
       mi->inc_pos(event_len);
+      mi->last_log_seq = ev->log_seq;
       flush_master_info(mi);
       delete ev;
       thd->log_seq = 0;
@@ -1170,6 +1183,7 @@
           mi->inc_pos(event_len);
           flush_master_info(mi);
 	}
+      mi->last_log_seq = ev->log_seq;
       delete ev;
       thd->log_seq = 0;
       break;
@@ -1185,21 +1199,26 @@
       if (!*log_name || !(log_name[ident_len] == 0 &&
 	   !memcmp(log_name, rev->new_log_ident, ident_len)))
       {
-	write_slave_event = mysql_bin_log.is_open();
-	rotate_binlog = (*log_name && write_slave_event );
+	write_slave_event = (!(rev->flags & LOG_EVENT_FORCED_ROTATE_F)
+			 && mysql_bin_log.is_open());
+	rotate_binlog = (*log_name && write_slave_event);
         memcpy(log_name, rev->new_log_ident,ident_len );
         log_name[ident_len] = 0;
       }
       mi->pos = 4; // skip magic number
+      mi->last_log_seq = ev->log_seq;
       pthread_cond_broadcast(&mi->cond);
       pthread_mutex_unlock(&mi->lock);
-      flush_master_info(mi);
 #ifndef DBUG_OFF
       if (abort_slave_event_count)
 	++events_till_abort;
 #endif
       if (rotate_binlog)
+      {
+	mi->last_log_seq = 0;
 	mysql_bin_log.new_file();
+      }
+      flush_master_info(mi);
       
       if (write_slave_event)
       {

--- 1.17/sql/slave.h	Wed May 30 18:50:54 2001
+++ 1.18/sql/slave.h	Sat Jun 23 19:37:23 2001
@@ -15,11 +15,12 @@
   char password[HASH_PASSWORD_LENGTH+1];
   uint port;
   uint connect_retry;
+  uint32 last_log_seq; // log sequence number of last processed event
   pthread_mutex_t lock;
   pthread_cond_t cond;
   bool inited;
   
-  st_master_info():pending(0),fd(-1),inited(0)
+  st_master_info():pending(0),fd(-1),last_log_seq(0),inited(0)
   {
     host[0] = 0; user[0] = 0; password[0] = 0;
     pthread_mutex_init(&lock, MY_MUTEX_INIT_FAST);

--- 1.8/mysql-test/r/rpl000014.result	Tue Jun 19 15:03:47 2001
+++ 1.9/mysql-test/r/rpl000014.result	Sat Jun 23 19:37:23 2001
@@ -1,13 +1,13 @@
 File	Position	Binlog_do_db	Binlog_ignore_db
 master-bin.001	79		
-Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter
-127.0.0.1	root	9999	1	master-bin.001	79	Yes			0		0
-Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter
-127.0.0.1	root	9999	1	master-bin.001	73	No			0		0
-Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter
-127.0.0.1	root	9999	1	master-bin.001	73	Yes			0		0
-Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter
-127.0.0.1	root	9999	1	master-bin.001	173	Yes			0		0
+Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter	Last_log_seq
+127.0.0.1	root	9999	1	master-bin.001	79	Yes			0		0	1
+Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter	Last_log_seq
+127.0.0.1	root	9999	1	master-bin.001	73	No			0		0	1
+Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter	Last_log_seq
+127.0.0.1	root	9999	1	master-bin.001	73	Yes			0		0	1
+Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter	Last_log_seq
+127.0.0.1	root	9999	1	master-bin.001	173	Yes			0		0	1
 File	Position	Binlog_do_db	Binlog_ignore_db
 master-bin.001	79		
 n

--- 1.7/mysql-test/r/rpl000015.result	Tue Jun 19 15:03:47 2001
+++ 1.8/mysql-test/r/rpl000015.result	Sat Jun 23 19:37:23 2001
@@ -1,13 +1,13 @@
 File	Position	Binlog_do_db	Binlog_ignore_db
 master-bin.001	79		
-Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter
-		0	0		0	No			0		0
-Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter
-127.0.0.1	test	9998	60		4	No			0		0
-Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter
-127.0.0.1	root	9999	60		4	No			0		0
-Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter
-127.0.0.1	root	9999	60	master-bin.001	79	Yes			0		0
+Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter	Last_log_seq
+		0	0		0	No			0		0	0
+Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter	Last_log_seq
+127.0.0.1	test	9998	60		4	No			0		0	0
+Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter	Last_log_seq
+127.0.0.1	root	9999	60		4	No			0		0	0
+Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter	Last_log_seq
+127.0.0.1	root	9999	60	master-bin.001	79	Yes			0		0	1
 n
 10
 45

--- 1.11/mysql-test/r/rpl000016.result	Tue Jun 19 15:03:47 2001
+++ 1.12/mysql-test/r/rpl000016.result	Sat Jun 23 19:37:23 2001
@@ -1,5 +1,5 @@
-Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter
-127.0.0.1	root	9999	60	master-bin.001	234	Yes			0		0
+Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter	Last_log_seq
+127.0.0.1	root	9999	60	master-bin.001	234	Yes			0		0	3
 s
 Could not break slave
 Tried hard
@@ -9,8 +9,8 @@
 master-bin.003
 Log_name
 master-bin.003
-Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter
-127.0.0.1	root	9999	60	master-bin.003	202	Yes			0		0
+Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter	Last_log_seq
+127.0.0.1	root	9999	60	master-bin.003	202	Yes			0		0	3
 m
 34
 65
@@ -24,7 +24,7 @@
 master-bin.006
 File	Position	Binlog_do_db	Binlog_ignore_db
 master-bin.006	720		
-Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter
-127.0.0.1	root	9999	60	master-bin.006	720	Yes			0		0
+Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter	Last_log_seq
+127.0.0.1	root	9999	60	master-bin.006	720	Yes			0		0	11
 count(*)
 100

--- 1.2/mysql-test/r/rpl_log.result	Fri Jun 22 08:35:17 2001
+++ 1.3/mysql-test/r/rpl_log.result	Sat Jun 23 19:37:23 2001
@@ -27,6 +27,9 @@
 master-bin.001	549	Stop	1	10	
 Log_name	Pos	Event_type	Server_id	Log_seq	Info
 master-bin.002	4	Start	1	1	Server ver: 4.0.0-debug-log, Binlog ver: 2
+master-bin.002	79	Query	1	2	use test; create table t1 (n int)
+master-bin.002	137	Query	1	3	use test; insert into t1 values (1)
+master-bin.002	197	Query	1	4	use test; drop table t1
 Log_name
 master-bin.001
 master-bin.002
@@ -42,8 +45,13 @@
 slave-bin.001	316	Query	1	5	use test; drop table t1
 slave-bin.001	364	Query	1	6	use test; create table t1 (word char(20) not null)
 slave-bin.001	439	Query	1	8	use test; drop table t1
-slave-bin.001	487	Rotate	2	3	slave-bin.002
+slave-bin.001	487	Rotate	2	3	slave-bin.002; forced by master
 slave-bin.001	519	Stop	2	4	
 Log_name	Pos	Event_type	Server_id	Log_seq	Info
 slave-bin.002	4	Start	2	1	Server ver: 4.0.0-debug-log, Binlog ver: 2
 slave-bin.002	79	Slave	2	2	host=127.0.0.1,port=9306,log=master-bin.002,pos=4
+slave-bin.002	132	Query	1	2	use test; create table t1 (n int)
+slave-bin.002	190	Query	1	3	use test; insert into t1 values (1)
+slave-bin.002	250	Query	1	4	use test; drop table t1
+Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter	Last_log_seq
+127.0.0.1	root	9999	1	master-bin.002	245	Yes			0		0	4

--- 1.2/mysql-test/t/rpl000017-slave.sh	Tue Jan 30 20:40:23 2001
+++ 1.3/mysql-test/t/rpl000017-slave.sh	Sat Jun 23 19:37:23 2001
@@ -6,4 +6,5 @@
 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 9306
 1
+0
 EOF

--- 1.2/mysql-test/t/rpl_log.test	Fri Jun 22 08:35:17 2001
+++ 1.3/mysql-test/t/rpl_log.test	Sat Jun 23 19:37:23 2001
@@ -20,6 +20,9 @@
 show binlog events from 79 limit 2;
 show binlog events from 79 limit 2,1;
 flush logs;
+create table t1 (n int);
+insert into t1 values (1);
+drop table t1;
 show binlog events;
 show binlog events in 'master-bin.002';
 show master logs;
@@ -30,3 +33,5 @@
 show master logs;
 show binlog events in 'slave-bin.001' from 4;
 show binlog events in 'slave-bin.002' from 4;
+--replace_result 9306 9999 3334 9999 3335 9999
+show slave status;
Thread
bk commit into 3.23 treesasha24 Jun