List:Internals« Previous MessageNext Message »
From:vva Date:January 29 2004 7:40pm
Subject:bk commit into 5.0 tree (vva:1.1649)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of vva. When vva 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://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet
  1.1649 04/01/29 22:40:04 vva@stripped +5 -0
  fixed bug #2342 "Running ANALYZE TABLE on bdb table 
   inside a transaction hangs server thread"

  sql/sql_table.cc
    1.176 04/01/29 22:39:30 vva@stripped +6 -0
    added new value of table checking

  sql/handler.h
    1.96 04/01/29 22:39:30 vva@stripped +1 -0
    added new value of table checking

  sql/ha_berkeley.cc
    1.122 04/01/29 22:39:30 vva@stripped +37 -0
    added checking of committed state for 
    bug #2342 "Running ANALYZE TABLE on bdb table 
     inside a transaction hangs server thread"

  mysql-test/t/bdb-crash.test
    1.10 04/01/29 22:39:30 vva@stripped +12 -0
    added test for bug #2342 "Running ANALYZE TABLE on bdb table 
     inside a transaction hangs server thread"

  mysql-test/r/bdb-crash.result
    1.7 04/01/29 22:39:30 vva@stripped +7 -0
    added test for bug #2342 "Running ANALYZE TABLE on bdb table 
     inside a transaction hangs server thread"

# 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:	vva
# Host:	eagle.mysql.r18.ru
# Root:	/home/vva/work/BUG_2342/mysql-5.0

--- 1.121/sql/ha_berkeley.cc	Wed Nov 19 15:53:00 2003
+++ 1.122/sql/ha_berkeley.cc	Thu Jan 29 22:39:30 2004
@@ -2121,6 +2121,43 @@
 {
   DB_BTREE_STAT *stat=0;
   uint i;
+  DB_TXN_STAT *txn_stat= 0;
+
+  /*
+   Original bdb documentation says:
+      "The DB->stat method cannot be transaction-protected. 
+      For this reason, it should be called in a thread of 
+      control that has no open cursors or active transactions."
+   So, let's check if there are any changes have been done since 
+     the beginning of the transaction..
+  */
+  if (!db_env->txn_stat(db_env, &txn_stat, 0) &&
+      txn_stat && txn_stat->st_nactive>=2)
+  {
+    DB_TXN_ACTIVE *atxn_stmt= 0, *atxn_all= 0;
+    
+    DB_TXN *txn_all= (DB_TXN*) thd->transaction.all.bdb_tid;
+    u_int32_t all_id= txn_all->id(txn_all);
+    
+    DB_TXN *txn_stmt= (DB_TXN*) thd->transaction.stmt.bdb_tid;
+    u_int32_t stmt_id= txn_stmt->id(txn_stmt);
+    
+    DB_TXN_ACTIVE *cur= txn_stat->st_txnarray;
+    DB_TXN_ACTIVE *end= cur + txn_stat->st_nactive;
+    for (; cur!=end && (!atxn_stmt || !atxn_all); cur++)
+    {
+      if (cur->txnid==all_id) atxn_all= cur;
+      if (cur->txnid==stmt_id) atxn_stmt= cur;
+    }
+    
+    if (atxn_stmt && atxn_all &&
+	log_compare(&atxn_stmt->lsn,&atxn_all->lsn))
+    {
+      free(txn_stat);
+      return HA_ADMIN_REJECT;
+    }
+    free(txn_stat);
+  }
 
   for (i=0 ; i < table->keys ; i++)
   {

--- 1.95/sql/handler.h	Sat Dec 20 01:54:33 2003
+++ 1.96/sql/handler.h	Thu Jan 29 22:39:30 2004
@@ -41,6 +41,7 @@
 #define HA_ADMIN_CORRUPT         -3
 #define HA_ADMIN_INTERNAL_ERROR  -4
 #define HA_ADMIN_INVALID         -5
+#define HA_ADMIN_REJECT          -6
 
 /* Bits in table_flags() to show what database can do */
 #define HA_READ_RND_SAME        1       /* Read RND-record to KEY-record

--- 1.175/sql/sql_table.cc	Fri Dec 19 23:13:44 2003
+++ 1.176/sql/sql_table.cc	Thu Jan 29 22:39:30 2004
@@ -1525,6 +1525,12 @@
       protocol->store("Operation failed",16, system_charset_info);
       break;
 
+    case HA_ADMIN_REJECT:
+      protocol->store("status", 6, system_charset_info);
+      protocol->store("Operation need committed state",30, system_charset_info);
+      open_for_modify= false;
+      break;
+
     case HA_ADMIN_ALREADY_DONE:
       protocol->store("status", 6, system_charset_info);
       protocol->store("Table is already up to date", 27, system_charset_info);

--- 1.6/mysql-test/r/bdb-crash.result	Wed Dec 10 08:30:12 2003
+++ 1.7/mysql-test/r/bdb-crash.result	Thu Jan 29 22:39:30 2004
@@ -30,3 +30,10 @@
 1	1	2001-03-01	1.00	1.00	1.00	New	blablabla	NULL	now
 2	1	2001-03-01	1.00	1.00	1.00	New	NULL	NULL	now
 drop table t1;
+create table t1 (a int) engine=bdb;
+set autocommit=0;
+insert into t1 values(1);
+analyze table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	status	Operation need committed state
+drop table t1;

--- 1.9/mysql-test/t/bdb-crash.test	Wed Dec 10 08:30:28 2003
+++ 1.10/mysql-test/t/bdb-crash.test	Thu Jan 29 22:39:30 2004
@@ -36,3 +36,15 @@
 VALUES(NULL,1,'2001-03-01',1,1,1,'New',NULL,NULL,'now');
 select * from t1;
 drop table t1;
+
+#
+# Test for bug #2342 "Running ANALYZE TABLE on bdb table 
+#                      inside a transaction hangs server thread"
+#
+
+create table t1 (a int) engine=bdb;
+
+set autocommit=0;
+insert into t1 values(1);
+analyze table t1;
+drop table t1;
\ No newline at end of file
Thread
bk commit into 5.0 tree (vva:1.1649)vva29 Jan