List:Internals« Previous MessageNext Message »
From:sasha Date:October 3 2001 7:55pm
Subject:bk commit into 4.0 tree
View as plain text  
Below is the list of changes that have just been committed into a
4.0 repository of sasha. When sasha does a push, they will be propogated to 
the main repository and within 24 hours after the push to the public repository. 
For information on how to access the public repository
see http://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet@stripped, 2001-10-03 13:55:31-06:00, sasha@stripped
  fixed slave to clean up load data infile temp files
  instrumented the server with DBUG_SYNC_POINT() macro

  sql/item_func.cc
    1.40 01/10/03 13:55:31 sasha@stripped +75 -4
    debug_sync_point()

  sql/log_event.cc
    1.60 01/10/03 13:55:31 sasha@stripped +22 -1
    clead load data file tmpdir on slave on start/stop events

  sql/mysql_priv.h
    1.124 01/10/03 13:55:31 sasha@stripped +13 -0
    DBUG_SYNC_POINT

  sql/sql_repl.cc
    1.59 01/10/03 13:55:31 sasha@stripped +1 -0
    DBUG_SYNC_POINT in Create_file_event

  mysql-test/t/rpl_log.test
    1.6 01/10/03 13:55:30 sasha@stripped +1 -0
    no change

# 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.39/sql/item_func.cc	Sun Sep  2 08:32:58 2001
+++ 1.40/sql/item_func.cc	Wed Oct  3 13:55:31 2001
@@ -1402,19 +1402,16 @@
   if (mysql_bin_log.is_open())
   {
     THD *thd = current_thd;
-    int save_errno;
     char buf[256];
     String tmp(buf,sizeof(buf));
     tmp.length(0);
     tmp.append("SELECT release_lock(\"");
     tmp.append(ull->key,ull->key_length);
     tmp.append("\")");
-    save_errno=thd->net.last_errno;
-    thd->net.last_errno=0;
     thd->query_length=tmp.length();
     Query_log_event qev(thd,tmp.ptr());
+    qev.error_code=0; // this query is always safe to run on slave
     mysql_bin_log.write(&qev);
-    thd->net.last_errno=save_errno;
   }
   if (--ull->count)
     pthread_cond_signal(&ull->cond);
@@ -1447,6 +1444,80 @@
   }
   return event_count;
 }
+
+#ifdef EXTRA_DEBUG
+void debug_sync_point(const char* lock_name, uint lock_timeout)
+{
+  THD* thd=current_thd;
+  ULL* ull;
+  struct timespec abstime;
+  int lock_name_len,error=0;
+  lock_name_len=strlen(lock_name);
+  pthread_mutex_lock(&LOCK_user_locks);
+
+  if (thd->ull)
+  {
+    item_user_lock_release(thd->ull);
+    thd->ull=0;
+  }
+
+  /* if the lock has not been aquired by some client, we do not want to
+     create an entry for it, since we immediately release the lock. In
+     this case, we will not be waiting, but rather, just waste CPU and
+     memory on the whole deal
+  */
+  if (!(ull= ((ULL*) hash_search(&hash_user_locks,lock_name,
+				 lock_name_len))))
+  {
+    pthread_mutex_unlock(&LOCK_user_locks);
+    return;
+  }
+  ull->count++;
+
+  /* structure is now initialized.  Try to get the lock */
+  /* Set up control struct to allow others to abort locks */
+  thd->proc_info="User lock";
+  thd->mysys_var->current_mutex= &LOCK_user_locks;
+  thd->mysys_var->current_cond=  &ull->cond;
+
+#ifdef HAVE_TIMESPEC_TS_SEC
+  abstime.ts_sec=time((time_t*) 0)+(time_t) lock_timeout;
+  abstime.ts_nsec=0;
+#else
+  abstime.tv_sec=time((time_t*) 0)+(time_t) lock_timeout;
+  abstime.tv_nsec=0;
+#endif
+
+  while (!thd->killed &&
+	 (error=pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime))
+	 != ETIME && error != ETIMEDOUT && ull->locked) ;
+  if (ull->locked)
+  {
+    if (!--ull->count)
+      delete ull;				// Should never happen
+  }
+  else
+  {
+    ull->locked=1;
+    ull->thread=thd->real_id;
+    thd->ull=ull;
+  }
+  pthread_mutex_unlock(&LOCK_user_locks);
+  pthread_mutex_lock(&thd->mysys_var->mutex);
+  thd->proc_info=0;
+  thd->mysys_var->current_mutex= 0;
+  thd->mysys_var->current_cond=  0;
+  pthread_mutex_unlock(&thd->mysys_var->mutex);
+  pthread_mutex_lock(&LOCK_user_locks);
+  if (thd->ull)
+  {
+    item_user_lock_release(thd->ull);
+    thd->ull=0;
+  }
+  pthread_mutex_unlock(&LOCK_user_locks);
+}
+
+#endif
 
 /*
   Get a user level lock. If the thread has an old lock this is first released.

--- 1.59/sql/log_event.cc	Mon Oct  1 16:13:54 2001
+++ 1.60/sql/log_event.cc	Wed Oct  3 13:55:31 2001
@@ -21,6 +21,7 @@
 #endif
 #include  "mysql_priv.h"
 #include "slave.h"
+#include <my_dir.h>
 #endif /* MYSQL_CLIENT */
 
 #ifdef MYSQL_CLIENT
@@ -127,6 +128,25 @@
     when = time(NULL);
   }
 }
+
+static void cleanup_load_tmpdir()
+{
+  MY_DIR *dirp;
+  FILEINFO *file;
+  uint i;
+  if (!(dirp=my_dir(slave_load_tmpdir,MYF(MY_WME))))
+    return;
+
+  for (i=0;i<(uint)dirp->number_off_files;i++)
+  {
+    file=dirp->dir_entry+i;
+    if (!memcmp(file->name,"SQL_LOAD-",9))
+      my_delete(file->name,MYF(MY_WME));
+  }
+
+  my_dirend(dirp);
+}
+
 #endif
 
 Log_event::Log_event(const char* buf):cached_event_len(0),temp_buf(0)
@@ -1638,6 +1658,7 @@
 int Start_log_event::exec_event(struct st_master_info* mi)
 {
   close_temporary_tables(thd);
+  cleanup_load_tmpdir();
   return Log_event::exec_event(mi);
 }
 
@@ -1646,7 +1667,7 @@
   if(mi->pos > 4) // stop event should be ignored after rotate event
   {
     close_temporary_tables(thd);
-    //clean_up_load_tmp_dir();
+    cleanup_load_tmpdir();
     mi->inc_pos(get_event_len(), log_seq);
     flush_master_info(mi);
   }

--- 1.123/sql/mysql_priv.h	Thu Sep 20 18:38:34 2001
+++ 1.124/sql/mysql_priv.h	Wed Oct  3 13:55:31 2001
@@ -190,6 +190,19 @@
 
 #define RAID_BLOCK_SIZE 1024
 
+// Sync points allow us to force the server to reach a certain line of code
+// and block there until the client tells the server it is ok to go on.
+// The client tells the server to block with SELECT GET_LOCK()
+// and unblocks it with SELECT RELEASE_LOCK(). Used for debugging difficult
+// concurrency problems
+#ifdef EXTRA_DEBUG
+#define DBUG_SYNC_POINT(lock_name,lock_timeout) \
+ debug_sync_point(lock_name,lock_timeout)
+void debug_sync_point(const char* lock_name, uint lock_timeout);
+#else
+#define DBUG_SYNC_POINT(lock_name,lock_timeout)
+#endif
+
 /* BINLOG_DUMP options */
 
 #define BINLOG_DUMP_NON_BLOCK   1

--- 1.5/mysql-test/t/rpl_log.test	Wed Jul  4 17:14:28 2001
+++ 1.6/mysql-test/t/rpl_log.test	Wed Oct  3 13:55:30 2001
@@ -46,3 +46,4 @@
  master_log_pos=4 and master_log_seq=1 and master_server_id=1;
 show new master for slave with master_log_file='master-bin.002' and
  master_log_pos=137 and master_log_seq=3 and master_server_id=1;
+

--- 1.58/sql/sql_repl.cc	Sat Sep 15 07:22:34 2001
+++ 1.59/sql/sql_repl.cc	Wed Oct  3 13:55:31 2001
@@ -1623,6 +1623,7 @@
 			    block_len);
     mysql_bin_log.write(&c);
     lf_info->wrote_create_file = 1;
+    DBUG_SYNC_POINT("debug_lock.created_file_event",10);
   }
   return 0;
 }
Thread
bk commit into 4.0 treesasha3 Oct