MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Martin Skold Date:August 15 2006 11:12am
Subject:bk commit into 4.1 tree (mskold:1.2537) BUG#21059
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of marty. When marty 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, 2006-08-15 13:12:27+02:00, mskold@stripped +5 -0
  ndb_lock.test, ndb_lock.result:
    bug #18184  SELECT ... FOR UPDATE does not work..: New test case
  ha_ndbcluster.h, ha_ndbcluster.cc, NdbConnection.hpp:
    Fix for bug #21059  Server crashes on join query with large dataset with NDB tables: Releasing operation for each intermediate batch, before next call to trans->execute(NoCommit);

  mysql-test/r/ndb_lock.result@stripped, 2006-08-15 13:09:09+02:00, mskold@stripped +12 -3
    bug #18184  SELECT ... FOR UPDATE does not work..: New test case

  mysql-test/t/ndb_lock.test@stripped, 2006-08-15 13:09:09+02:00, mskold@stripped +13 -2
    bug #18184  SELECT ... FOR UPDATE does not work..: New test case

  ndb/include/ndbapi/NdbConnection.hpp@stripped, 2006-08-15 13:09:39+02:00, mskold@stripped +3 -1
    Fix for bug #21059  Server crashes on join query with large dataset with NDB tables: Releasing operation for each intermediate batch, before next call to trans->execute(NoCommit);

  sql/ha_ndbcluster.cc@stripped, 2006-08-15 13:09:39+02:00, mskold@stripped +34 -0
    Fix for bug #21059  Server crashes on join query with large dataset with NDB tables: Releasing operation for each intermediate batch, before next call to trans->execute(NoCommit);

  sql/ha_ndbcluster.h@stripped, 2006-08-15 13:09:39+02:00, mskold@stripped +2 -0
    Fix for bug #21059  Server crashes on join query with large dataset with NDB tables: Releasing operation for each intermediate batch, before next call to trans->execute(NoCommit);

# 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:	mskold
# Host:	linux.site
# Root:	/windows/Linux_space/MySQL/mysql-4.1

--- 1.25/ndb/include/ndbapi/NdbConnection.hpp	2006-08-15 13:12:32 +02:00
+++ 1.26/ndb/include/ndbapi/NdbConnection.hpp	2006-08-15 13:12:32 +02:00
@@ -163,7 +163,8 @@ class NdbConnection
   friend class NdbIndexOperation;
   friend class NdbIndexScanOperation;
   friend class NdbBlob;
- 
+  friend class ha_ndbcluster;
+
 public:
 
   /**
@@ -675,6 +676,7 @@ private:						
   // optim: any blobs
   bool theBlobFlag;
   Uint8 thePendingBlobOps;
+  inline bool hasBlobOperation() { return theBlobFlag; }
 
   static void sendTC_COMMIT_ACK(NdbApiSignal *,
 				Uint32 transId1, Uint32 transId2, 

--- 1.190/sql/ha_ndbcluster.cc	2006-08-15 13:12:32 +02:00
+++ 1.191/sql/ha_ndbcluster.cc	2006-08-15 13:12:32 +02:00
@@ -161,6 +161,7 @@ int execute_no_commit(ha_ndbcluster *h, 
   if (m_batch_execute)
     return 0;
 #endif
+  h->release_completed_operations(trans);
   return trans->execute(NoCommit,AbortOnError,h->m_force_send);
 }
 
@@ -194,6 +195,7 @@ int execute_no_commit_ie(ha_ndbcluster *
   if (m_batch_execute)
     return 0;
 #endif
+  h->release_completed_operations(trans);
   return trans->execute(NoCommit, AO_IgnoreError,h->m_force_send);
 }
 
@@ -2747,6 +2749,25 @@ int ha_ndbcluster::close_scan()
   if (!cursor)
     DBUG_RETURN(1);
 
+  if (m_lock_tuple)
+  {
+    /*
+      Lock level m_lock.type either TL_WRITE_ALLOW_WRITE
+      (SELECT FOR UPDATE) or TL_READ_WITH_SHARED_LOCKS (SELECT
+      LOCK WITH SHARE MODE) and row was not explictly unlocked 
+      with unlock_row() call
+    */
+      NdbOperation *op;
+      // Lock row
+      DBUG_PRINT("info", ("Keeping lock on scanned row"));
+      
+      if (!(op= m_active_cursor->lockTuple()))
+      {
+	m_lock_tuple= false;
+	ERR_RETURN(trans->getNdbError());
+      }
+      m_ops_pending++;      
+  }
   m_lock_tuple= false;
   if (m_ops_pending)
   {
@@ -5348,6 +5369,19 @@ int ha_ndbcluster::write_ndb_file()
     my_close(file,MYF(0));
   }
   DBUG_RETURN(error);
+}
+
+void 
+ha_ndbcluster::release_completed_operations(NdbConnection *trans)
+{
+  if (trans->hasBlobOperation())
+  {
+    /* We are reading/writing BLOB fields, 
+       releasing operation records is unsafe
+    */
+    return;
+  }
+  trans->releaseCompletedOperations();
 }
 
 int

--- 1.59/sql/ha_ndbcluster.h	2006-08-15 13:12:32 +02:00
+++ 1.60/sql/ha_ndbcluster.h	2006-08-15 13:12:32 +02:00
@@ -262,6 +262,8 @@ class ha_ndbcluster: public handler
   void no_uncommitted_rows_init(THD *);
   void no_uncommitted_rows_reset(THD *);
 
+  void release_completed_operations(NdbConnection*);
+
   friend int execute_no_commit(ha_ndbcluster*, NdbConnection*);
   friend int execute_commit(ha_ndbcluster*, NdbConnection*);
   friend int execute_no_commit_ie(ha_ndbcluster*, NdbConnection*);

--- 1.8/mysql-test/r/ndb_lock.result	2006-08-15 13:12:32 +02:00
+++ 1.9/mysql-test/r/ndb_lock.result	2006-08-15 13:12:32 +02:00
@@ -64,17 +64,26 @@ pk	u	o
 insert into t1 values (1,1,1);
 drop table t1;
 create table t1 (x integer not null primary key, y varchar(32), z integer, key(z)) engine = ndb;
-insert into t1 values (1,'one',1), (2,'two',2),(3,"three",3);
+insert into t1 values (1,'one',1);
 begin;
 select * from t1 where x = 1 for update;
 x	y	z
 1	one	1
 begin;
-select * from t1 where x = 2 for update;
+select * from t1 where x = 1 for update;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+rollback;
+rollback;
+insert into t1 values (2,'two',2),(3,"three",3);
+begin;
+select * from t1 where x = 1 for update;
 x	y	z
-2	two	2
+1	one	1
 select * from t1 where x = 1 for update;
 ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+select * from t1 where x = 2 for update;
+x	y	z
+2	two	2
 rollback;
 commit;
 begin;

--- 1.10/mysql-test/t/ndb_lock.test	2006-08-15 13:12:32 +02:00
+++ 1.11/mysql-test/t/ndb_lock.test	2006-08-15 13:12:32 +02:00
@@ -73,7 +73,7 @@ drop table t1;
 
 create table t1 (x integer not null primary key, y varchar(32), z integer, key(z)) engine = ndb;
 
-insert into t1 values (1,'one',1), (2,'two',2),(3,"three",3); 
+insert into t1 values (1,'one',1);
 
 # PK access
 connection con1;
@@ -82,9 +82,20 @@ select * from t1 where x = 1 for update;
 
 connection con2;
 begin;
-select * from t1 where x = 2 for update;
 --error 1205
 select * from t1 where x = 1 for update;
+rollback;
+
+connection con1;
+rollback;
+insert into t1 values (2,'two',2),(3,"three",3); 
+begin;
+select * from t1 where x = 1 for update;
+
+connection con2;
+--error 1205
+select * from t1 where x = 1 for update;
+select * from t1 where x = 2 for update;
 rollback;
 
 connection con1;
Thread
bk commit into 4.1 tree (mskold:1.2537) BUG#21059Martin Skold15 Aug