[Commits] Rev 3513: MDEV-530: Cassandra SE: Locking is incorrect in file:///data0/psergey/dev2/5.5-cassandra-r01/

Sergey Petrunya psergey at askmonty.org
Fri Sep 14 08:25:42 EEST 2012


At file:///data0/psergey/dev2/5.5-cassandra-r01/

------------------------------------------------------------
revno: 3513
revision-id: psergey at askmonty.org-20120914052542-36jdl4nc4bfgqeb9
parent: psergey at askmonty.org-20120914050325-cdnly2zfiziwajnw
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: 5.5-cassandra-r01
timestamp: Fri 2012-09-14 09:25:42 +0400
message:
  MDEV-530: Cassandra SE: Locking is incorrect
  - Use more permissive locking.
=== modified file 'storage/cassandra/ha_cassandra.cc'
--- a/storage/cassandra/ha_cassandra.cc	2012-09-12 16:52:23 +0000
+++ b/storage/cassandra/ha_cassandra.cc	2012-09-14 05:25:42 +0000
@@ -1420,14 +1420,41 @@
 }
 
 
+/* The following function was copied from ha_blackhole::store_lock: */
 THR_LOCK_DATA **ha_cassandra::store_lock(THD *thd,
-                                       THR_LOCK_DATA **to,
-                                       enum thr_lock_type lock_type)
+                                         THR_LOCK_DATA **to,
+                                         enum thr_lock_type lock_type)
 {
+  DBUG_ENTER("ha_cassandra::store_lock");
   if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
-    lock.type=lock_type;
+  {
+    /*
+      Here is where we get into the guts of a row level lock.
+      If TL_UNLOCK is set
+      If we are not doing a LOCK TABLE or DISCARD/IMPORT
+      TABLESPACE, then allow multiple writers
+    */
+
+    if ((lock_type >= TL_WRITE_CONCURRENT_INSERT &&
+         lock_type <= TL_WRITE) && !thd_in_lock_tables(thd)
+        && !thd_tablespace_op(thd))
+      lock_type = TL_WRITE_ALLOW_WRITE;
+
+    /*
+      In queries of type INSERT INTO t1 SELECT ... FROM t2 ...
+      MySQL would use the lock TL_READ_NO_INSERT on t2, and that
+      would conflict with TL_WRITE_ALLOW_WRITE, blocking all inserts
+      to t2. Convert the lock to a normal read lock to allow
+      concurrent inserts to t2.
+    */
+
+    if (lock_type == TL_READ_NO_INSERT && !thd_in_lock_tables(thd))
+      lock_type = TL_READ;
+
+    lock.type= lock_type;
+  }
   *to++= &lock;
-  return to;
+  DBUG_RETURN(to);
 }
 
 



More information about the commits mailing list