db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r123267 - in incubator/derby/code/trunk/java: engine/org/apache/derby/impl/store/raw/xact testing/org/apache/derbyTesting/functionTests/master testing/org/apache/derbyTesting/functionTests/suites testing/org/apache/derbyTesting/functionTests/tests/storetests
Date Fri, 24 Dec 2004 03:20:46 GMT
Author: mikem
Date: Thu Dec 23 19:20:45 2004
New Revision: 123267

URL: http://svn.apache.org/viewcvs?view=rev&rev=123267
Log:
committing patch to fix DERBY-94 submitted by Suresh Thalamati (tsuresh@Source-Zone.org)
Problem:
Container group level locks were not getting released when lock is
escalated to table level exclusive lock. Locks were not getting released
even on commit/close of cursor   because once escalation process
acquires table level X lock successfully, container group lock policy is
set as NO-LOCKING state.

Fix:
Attached Fix releases the container group level locks before setting
lock policy to  NO LOCKING mode when a table level X lock is acquired
because of escalation.


Added:
   incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derby94.out
   incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/derby94.sql
   incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/derby94_derby.properties
Modified:
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/RowLocking2.java
   incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storetests.runall
   incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/copyfiles.ant

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/RowLocking2.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/RowLocking2.java?view=diff&rev=123267&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/RowLocking2.java&r1=123266&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/RowLocking2.java&r2=123267
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/RowLocking2.java
(original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/RowLocking2.java
Thu Dec 23 19:20:45 2004
@@ -115,13 +115,17 @@
             //
 
 
-			if (lf.isLockHeld(t.getCompatibilitySpace(), t, container.getId(), ContainerLock.CX) ||
-				((!forUpdate) && 
-                 lf.isLockHeld(t.getCompatibilitySpace(), t, container.getId(), ContainerLock.CS)))
+			if (lf.isLockHeld(t.getCompatibilitySpace(), t, container.getId(),
+							  ContainerLock.CX))
+			{
+				//release any container group locks becuase CX container lock will cover everthing.
+				lf.unlockGroup(t.getCompatibilitySpace(), container.getUniqueId());
+				container.setLockingPolicy(NO_LOCK);
+			}else if ((!forUpdate) && 
+					 lf.isLockHeld(t.getCompatibilitySpace(), t, container.getId(), ContainerLock.CS))
             {
-                // move lock from container group to transaction group.
-                if (!forUpdate)
-                    lf.transfer(t.getCompatibilitySpace(), group, t);
+                // move locks from container group to transaction group.
+				lf.transfer(t.getCompatibilitySpace(), group, t);
 				container.setLockingPolicy(NO_LOCK);
 			}
 		}

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derby94.out
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derby94.out?view=auto&rev=123267
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derby94.out
Thu Dec 23 19:20:45 2004
@@ -0,0 +1,83 @@
+ij> create view lock_table as select 
+cast(l.type as char(8)) as type,cast(lockcount as char(3)) as
+cnt,mode,cast(tablename as char(12)) as tabname,cast(lockname as char(10))
+as lockname,state from new org.apache.derby.diag.LockTable() l ;
+0 rows inserted/updated/deleted
+ij> autocommit off;
+ij> create table derby94_t1(c1 int, c2 int not null primary key);
+0 rows inserted/updated/deleted
+ij> create table derby94_t2(c1 int);
+0 rows inserted/updated/deleted
+ij> insert into derby94_t1 values (0, 200), (1, 201), (2, 202), (3, 203), (4, 204), (5,
205), (6, 206), (7, 207), (8, 208), (9, 209);
+10 rows inserted/updated/deleted
+ij> insert into derby94_t1 select c1+10 , c2 +10 from derby94_t1;
+10 rows inserted/updated/deleted
+ij> insert into derby94_t1 select c1+20 , c2 +20 from derby94_t1;
+20 rows inserted/updated/deleted
+ij> insert into derby94_t1 select c1+40 , c2 +40 from derby94_t1;
+40 rows inserted/updated/deleted
+ij> insert into derby94_t1 select c1+80 , c2 +80 from derby94_t1;
+80 rows inserted/updated/deleted
+ij> insert into derby94_t2 values (0), (1), (2), (3), (4), (5), (6), (7), (8), (9);
+10 rows inserted/updated/deleted
+ij> commit;
+ij> get cursor c1 as 'select * from derby94_t1 FOR UPDATE of c1';
+ij> next c1;
+C1         |C2         
+-----------------------
+0          |200        
+ij> update derby94_t1 set c1=c1+999 WHERE CURRENT OF c1;
+1 row inserted/updated/deleted
+ij> next c1;
+C1         |C2         
+-----------------------
+1          |201        
+ij> get cursor c2 as 'select *  from derby94_t2 FOR UPDATE of c1';
+ij> next c2 ;
+C1         
+-----------
+0          
+ij> select * from lock_table order by tabname, type desc, mode, cnt, lockname ;
+TYPE    |CNT |MODE|TABNAME     |LOCKNAME  |STATE
+------------------------------------------------
+TABLE   |2   |IX  |DERBY94_T1  |Tablelock |GRANT
+ROW     |1   |U   |DERBY94_T1  |(1,8)     |GRANT
+ROW     |1   |X   |DERBY94_T1  |(1,7)     |GRANT
+TABLE   |1   |IX  |DERBY94_T2  |Tablelock |GRANT
+ROW     |1   |U   |DERBY94_T2  |(1,7)     |GRANT
+ij> --following insert should get X lock on derby94_t2 because of escalation , but should
leave U lock on derby94_t1 as it is
+insert into derby94_t2 select c1 from derby94_t1 ;
+160 rows inserted/updated/deleted
+ij> select * from lock_table order by tabname, type desc, mode, cnt, lockname ;
+TYPE    |CNT |MODE|TABNAME     |LOCKNAME  |STATE
+------------------------------------------------
+TABLE   |3   |IX  |DERBY94_T1  |Tablelock |GRANT
+ROW     |1   |U   |DERBY94_T1  |(1,8)     |GRANT
+ROW     |1   |X   |DERBY94_T1  |(1,7)     |GRANT
+TABLE   |4   |IX  |DERBY94_T2  |Tablelock |GRANT
+TABLE   |1   |X   |DERBY94_T2  |Tablelock |GRANT
+ij> --following update statement should escalate the locks on derby94_t1 to table level
X lock
+update derby94_t1 set c1=c1+999 ;
+160 rows inserted/updated/deleted
+ij> select * from lock_table order by tabname, type desc, mode, cnt, lockname ;
+TYPE    |CNT |MODE|TABNAME     |LOCKNAME  |STATE
+------------------------------------------------
+TABLE   |8   |IX  |DERBY94_T1  |Tablelock |GRANT
+TABLE   |1   |X   |DERBY94_T1  |Tablelock |GRANT
+TABLE   |4   |IX  |DERBY94_T2  |Tablelock |GRANT
+TABLE   |1   |X   |DERBY94_T2  |Tablelock |GRANT
+ij> close c1 ;
+ij> close c2 ;
+ij> commit ;
+ij> --following lock table dump should not show any  locks, above commit should have release
them
+select * from lock_table order by tabname, type desc, mode, cnt, lockname;
+TYPE    |CNT |MODE|TABNAME     |LOCKNAME  |STATE
+------------------------------------------------
+ij> drop table derby94_t1;
+0 rows inserted/updated/deleted
+ij> drop table derby94_t2;
+0 rows inserted/updated/deleted
+ij> commit;
+ij> --end derby-94 case
+;
+ij> 

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storetests.runall
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storetests.runall?view=diff&rev=123267&p1=incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storetests.runall&r1=123266&p2=incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storetests.runall&r2=123267
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storetests.runall
(original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storetests.runall
Thu Dec 23 19:20:45 2004
@@ -1,3 +1,4 @@
 storetests/st_schema.sql
 storetests/st_1.sql
 storetests/st_b5772.sql
+storetests/derby94.sql

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/copyfiles.ant
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/copyfiles.ant?view=diff&rev=123267&p1=incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/copyfiles.ant&r1=123266&p2=incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/copyfiles.ant&r2=123267
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/copyfiles.ant
(original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/copyfiles.ant
Thu Dec 23 19:20:45 2004
@@ -4,3 +4,5 @@
 st_schema_app.properties
 st_1.sql
 st_b5772.sql
+derby94.sql
+derby94_derby.properties

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/derby94.sql
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/derby94.sql?view=auto&rev=123267
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/derby94.sql
Thu Dec 23 19:20:45 2004
@@ -0,0 +1,39 @@
+create view lock_table as select 
+cast(l.type as char(8)) as type,cast(lockcount as char(3)) as
+cnt,mode,cast(tablename as char(12)) as tabname,cast(lockname as char(10))
+as lockname,state from new org.apache.derby.diag.LockTable() l ;
+autocommit off;
+create table derby94_t1(c1 int, c2 int not null primary key);
+create table derby94_t2(c1 int);
+insert into derby94_t1 values (0, 200), (1, 201), (2, 202), (3, 203), (4, 204), (5, 205),
(6, 206), (7, 207), (8, 208), (9, 209);
+insert into derby94_t1 select c1+10 , c2 +10 from derby94_t1;
+insert into derby94_t1 select c1+20 , c2 +20 from derby94_t1;
+insert into derby94_t1 select c1+40 , c2 +40 from derby94_t1;
+insert into derby94_t1 select c1+80 , c2 +80 from derby94_t1;
+insert into derby94_t2 values (0), (1), (2), (3), (4), (5), (6), (7), (8), (9);
+commit;
+get cursor c1 as 'select * from derby94_t1 FOR UPDATE of c1';
+next c1;
+update derby94_t1 set c1=c1+999 WHERE CURRENT OF c1;
+next c1;
+get cursor c2 as 'select *  from derby94_t2 FOR UPDATE of c1';
+next c2 ;
+
+select * from lock_table order by tabname, type desc, mode, cnt, lockname ;
+--following insert should get X lock on derby94_t2 because of escalation , but should leave
U lock on derby94_t1 as it is
+insert into derby94_t2 select c1 from derby94_t1 ;
+select * from lock_table order by tabname, type desc, mode, cnt, lockname ;
+
+--following update statement should escalate the locks on derby94_t1 to table level X lock
+update derby94_t1 set c1=c1+999 ;
+select * from lock_table order by tabname, type desc, mode, cnt, lockname ;
+close c1 ;
+close c2 ;
+commit ;
+--following lock table dump should not show any  locks, above commit should have release
them
+select * from lock_table order by tabname, type desc, mode, cnt, lockname;
+drop table derby94_t1;
+drop table derby94_t2;
+commit;
+--end derby-94 case
+

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/derby94_derby.properties
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/derby94_derby.properties?view=auto&rev=123267
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/derby94_derby.properties
Thu Dec 23 19:20:45 2004
@@ -0,0 +1,2 @@
+#modify the lock escalation threshold to smaller value to make testing simple
+derby.locks.escalationThreshold=102

Mime
View raw message