List:Commits« Previous MessageNext Message »
From:Tatjana A Nuernberg Date:June 27 2007 11:00am
Subject:bk commit into 4.0 tree (tnurnberg:1.2214) BUG#27198
View as plain text  
Below is the list of changes that have just been committed into a local
4.0 repository of tnurnberg. When tnurnberg does a push these changes will
be propagated 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://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-06-27 13:00:00+02:00, tnurnberg@stripped +1 -0
  Bug#27198: Error returns from time() are ignored
  
  gettimeofday() can fail and presumably, so can time().
  Keep an eye on it.
  
  Since we have no data on this at all so far, we just
  retry on failure (and log the event), assuming that
  this is just an intermittant failure. This might of
  course hang the threat until we succeed. Once we know
  more about these failures, an appropriate more clever
  scheme may be picked (only try so many times per thread,
  etc., if that fails, return last "good" time() we got or
  some such).  Using sql_print_information() to log as this
  probably only occurs in high load scenarios where the debug-
  trace likely is disabled (or might interfere with testing
  the effect).  No test-case as this is a non-deterministic
  issue.

  sql/sql_class.h@stripped, 2007-06-27 12:59:59+02:00, tnurnberg@stripped +34 -16
    Bug#27198: Error returns from time() are ignored
    
    gettimeofday() can fail and presumably, so can time().
    Keep an eye on it.

# 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:	tnurnberg
# Host:	sin.intern.azundris.com
# Root:	/home/tnurnberg/27198/40-27198

--- 1.191/sql/sql_class.h	2004-12-03 00:02:39 +01:00
+++ 1.192/sql/sql_class.h	2007-06-27 12:59:59 +02:00
@@ -21,6 +21,8 @@
 #pragma interface			/* gcc class implementation */
 #endif
 
+void sql_print_information(const char *format, ...);
+
 // TODO: create log.h and move all the log header stuff there
 
 class Query_log_event;
@@ -113,7 +115,7 @@ public:
   {
 #ifndef DBUG_OFF
     char buf1[22],buf2[22];
-#endif	
+#endif
     DBUG_ENTER("harvest_bytes_written");
     (*counter)+=bytes_written;
     DBUG_PRINT("info",("counter: %s  bytes_written: %s", llstr(*counter,buf1),
@@ -148,7 +150,7 @@ public:
   */
   bool appendv(const char* buf,uint len,...);
   bool append(Log_event* ev);
-  
+
   int generate_new_name(char *new_name,const char *old_name);
   void make_log_name(char* buf, const char* log_ident);
   bool is_active(const char* log_file_name);
@@ -430,7 +432,7 @@ public:
   ULL	  *ull;
 #ifndef DBUG_OFF
   uint dbug_sentry; // watch out for memory corruption
-#endif  
+#endif
   struct st_my_thread_var *mysys_var;
   enum enum_server_command command;
   uint32     server_id;
@@ -471,7 +473,7 @@ public:
 #endif
 #ifdef SIGNAL_WITH_VIO_CLOSE
   Vio* active_vio;
-#endif  
+#endif
   ulonglong  next_insert_id,last_insert_id,current_insert_id,
              limit_found_rows;
   ha_rows    select_limit, offset_limit, cuted_fields,
@@ -509,7 +511,7 @@ public:
   */
   ulong	     slave_proxy_id;
   NET*       slave_net;			// network connection from slave -> m.
-   
+
   /* Used by the sys_var class to store temporary values */
   union
   {
@@ -537,7 +539,7 @@ public:
     pthread_mutex_unlock(&LOCK_delete);
   }
   void close_active_vio();
-#endif  
+#endif
   void awake(bool prepare_to_die);
   /*
     For enter_cond() / exit_cond() to work the mutex must be got before
@@ -569,17 +571,33 @@ public:
     proc_info = old_msg;
     pthread_mutex_unlock(&mysys_var->mutex);
   }
+
+  static inline void safe_time(time_t *t)
+  {
+    /**
+       Wrapper around time() which retries on error (-1)
+
+       @details
+       This is needed because, despite the documentation, time() may fail
+       in some circumstances.  Here we retry time() until it succeeds, and
+       log the failure so that performance problems related to this can be
+       identified.
+    */
+    while(unlikely(time(t) == ((time_t) -1)))
+      sql_print_information("time() failed with %d", errno);
+  }
+
   inline time_t query_start() { query_start_used=1; return start_time; }
-  inline void	set_time()    { if (user_time) start_time=time_after_lock=user_time; else time_after_lock=time(&start_time); }
-  inline void	end_time()    { time(&start_time); }
+  inline void	set_time()    { if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
+  inline void	end_time()    { safe_time(&start_time); }
   inline void	set_time(time_t t) { time_after_lock=start_time=user_time=t; }
-  inline void	lock_time()   { time(&time_after_lock); }
+  inline void	lock_time()   { safe_time(&time_after_lock); }
   inline void	insert_id(ulonglong id)
   { last_insert_id=id; insert_id_used=1; }
   inline ulonglong insert_id(void)
   {
     if (!last_insert_id_used)
-    {      
+    {
       last_insert_id_used=1;
       current_insert_id=last_insert_id;
     }
@@ -588,10 +606,10 @@ public:
   inline ulonglong found_rows(void)
   {
     return limit_found_rows;
-  }                                                                         
+  }
   inline bool active_transaction()
   {
-#ifdef USING_TRANSACTIONS    
+#ifdef USING_TRANSACTIONS
     return (transaction.all.bdb_tid != 0 ||
 	    transaction.all.innodb_active_trans != 0);
 #else
@@ -619,8 +637,8 @@ public:
       memcpy(ptr,str,size);
     return ptr;
   }
-  inline gptr trans_alloc(unsigned int size) 
-  { 
+  inline gptr trans_alloc(unsigned int size)
+  {
     return alloc_root(&transaction.mem_root,size);
   }
   void add_changed_table(TABLE *table);
@@ -640,11 +658,11 @@ public:
 # define tmp_disable_binlog(A)                                          \
   ulong save_options= (A)->options, save_master_access= (A)->master_access; \
   (A)->options&= ~OPTION_BIN_LOG;                                       \
-  (A)->master_access|= SUPER_ACL; /* unneeded in 4.1 */                 
+  (A)->master_access|= SUPER_ACL; /* unneeded in 4.1 */
 
 #define reenable_binlog(A)                      \
   (A)->options= save_options;                   \
-  (A)->master_access= save_master_access;       
+  (A)->master_access= save_master_access;
 
 /* Flags for the THD::system_thread (bitmap) variable */
 #define SYSTEM_THREAD_DELAYED_INSERT 1
Thread
bk commit into 4.0 tree (tnurnberg:1.2214) BUG#27198Tatjana A Nuernberg27 Jun