db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1068057 - in /db/derby/code/branches/10.5: ./ java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
Date Mon, 07 Feb 2011 19:11:26 GMT
Author: kmarsden
Date: Mon Feb  7 19:11:25 2011
New Revision: 1068057

URL: http://svn.apache.org/viewvc?rev=1068057&view=rev
Log:
DERBY-4881 Deadlock accessing SYS.SYSSTATISTICS

port to 10.5 
Contributed by Kristian Waagan


Modified:
    db/derby/code/branches/10.5/   (props changed)
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Feb  7 19:11:25 2011
@@ -1,2 +1,2 @@
-/db/derby/code/branches/10.6:942027,957000,962738,965351,987678,1055601
-/db/derby/code/trunk:757811,764912,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792001,792254,792434,793089,793588,794106,794276,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,891350,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915177,915733,916075,916897,917771,918152,918359,921028,927430,928065,929085,931076,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952581,954748,955001,955634,956075,956445,956659,958163,959550,962716,965647,967304,980684,986689,986834,999119,1002291,1002682,
 1002853,1021426,1025795,1040658,1053724,1055169,1062096,1063809,1065061,1067250
+/db/derby/code/branches/10.6:942027,957000,962738,965351,987678,1031623,1055601
+/db/derby/code/trunk:757811,764912,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792001,792254,792434,793089,793588,794106,794276,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,891350,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915177,915733,916075,916897,917771,918152,918359,921028,927430,928065,929085,931076,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952581,954748,955001,955634,956075,956445,956659,958163,959550,962716,965647,967304,980684,986689,986834,999119,1002291,1002682,
 1002853,1021426,1025795,1030043,1040658,1053724,1055169,1062096,1063809,1065061,1067250

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?rev=1068057&r1=1068056&r2=1068057&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
Mon Feb  7 19:11:25 2011
@@ -1624,6 +1624,7 @@ public final class	DataDictionaryImpl
 						(TupleDescriptor) null,
 						(List) null,
 						false,
+                        TransactionController.ISOLATION_REPEATABLE_READ,
 						tc);
 	}
 
@@ -5067,9 +5068,16 @@ public final class	DataDictionaryImpl
 					false);
 	}
 
-	/** get all the statistiscs descriptors for a given table.
-	 * @param  td	Table Descriptor for which I need statistics
-	 */
+    /**
+     * Returns all the statistics descriptors for the given table.
+     * <p>
+     * NOTE: As opposed to most other data dictionary lookups, this operation is
+     * performed with isolation level READ_UNCOMMITTED. The reason is to avoid
+     * deadlocks with inserts into the statistics system table.
+     *
+     * @param td {@code TableDescriptor} for which I need statistics
+     * @return A list of tuple descriptors, possibly empty.
+     */
 	public List getStatisticsDescriptors(TableDescriptor td)
 		throws StandardException
 	{
@@ -5081,13 +5089,16 @@ public final class	DataDictionaryImpl
 		UUIDStringOrderable = getIDValueAsCHAR(td.getUUID());
 		ExecIndexRow keyRow = exFactory.getIndexableRow(1);
 		keyRow.setColumn(1, UUIDStringOrderable);
-		
+
 		getDescriptorViaIndex(SYSSTATISTICSRowFactory.SYSSTATISTICS_INDEX1_ID,
-							  keyRow,
-							  (ScanQualifier [][])null,
-							  ti, 
-							  (TupleDescriptor)null,
-							  statDescriptorList, false);
+                              keyRow,
+                              (ScanQualifier [][])null,
+                              ti,
+                              (TupleDescriptor)null,
+                              statDescriptorList,
+                              false,
+                              TransactionController.ISOLATION_READ_UNCOMMITTED,
+                              getTransactionCompile());
 
 		return statDescriptorList;
 	}
@@ -8567,63 +8578,16 @@ public final class	DataDictionaryImpl
 		// Get the current transaction controller
 		TransactionController tc = getTransactionCompile();
 
-		return getDescriptorViaIndexMinion(
-			indexId,
-			keyRow,
-			scanQualifiers,
-			ti,
-			parentTupleDescriptor,
-			list,
-			forUpdate,
-			TransactionController.ISOLATION_REPEATABLE_READ,
-			tc);
-	}
-
-	/**
-	 * Return a (single or list of) catalog row descriptor(s) from a
-	 * system table where the access is from the index to the heap.
-	 *
-	 * This overload variant takes an explicit tc, in contrast to the normal
-	 * one which uses the one returned by getTransactionCompile.
-	 *
-	 * @param indexId	The id of the index (0 to # of indexes on table) to use
-	 * @param keyRow	The supplied ExecIndexRow for search
-	 * @param ti		The TabInfoImpl to use
-	 * @param parentTupleDescriptor		The parentDescriptor, if applicable.
-	 * @param list      The list to build, if supplied.  If null, then
-	 *					caller expects a single descriptor
-	 * @param forUpdate	Whether or not to open the index for update.
-	 * @param tc        Transaction controller
-	 *
-	 * @return	The last matching descriptor
-	 *
-	 * @exception StandardException		Thrown on error
-	 */
-	private final TupleDescriptor getDescriptorViaIndex(
-						int indexId,
-						ExecIndexRow keyRow,
-						ScanQualifier [][] scanQualifiers,
-						TabInfoImpl ti,
-						TupleDescriptor parentTupleDescriptor,
-						List list,
-						boolean forUpdate,
-						TransactionController tc)
-			throws StandardException
-	{
-		if (tc == null) {
-			tc = getTransactionCompile();
-		}
-
-		return getDescriptorViaIndexMinion(
-			indexId,
-			keyRow,
-			scanQualifiers,
-			ti,
-			parentTupleDescriptor,
-			list,
-			forUpdate,
-			TransactionController.ISOLATION_REPEATABLE_READ,
-			tc);
+        return getDescriptorViaIndexMinion(
+                indexId,
+                keyRow,
+                scanQualifiers,
+                ti,
+                parentTupleDescriptor,
+                list,
+                forUpdate,
+                TransactionController.ISOLATION_REPEATABLE_READ,
+                tc);
 	}
 
 	/**
@@ -8697,7 +8661,6 @@ public final class	DataDictionaryImpl
 		CatalogRowFactory		rf = ti.getCatalogRowFactory();
 		ConglomerateController	heapCC;
 		ExecIndexRow	  		indexRow1;
-		ExecIndexRow			indexTemplateRow;
 		ExecRow 				outRow;
 		RowLocation				baseRowLocation;
 		ScanController			scanController;
@@ -8709,13 +8672,6 @@ public final class	DataDictionaryImpl
 				 TransactionController.ISOLATION_REPEATABLE_READ ||
 				 isolationLevel ==
 				 TransactionController.ISOLATION_READ_UNCOMMITTED);
-
-			if (isolationLevel ==
-				 TransactionController.ISOLATION_READ_UNCOMMITTED) {
-				// list not used for this case
-				SanityManager.ASSERT(list == null);
-			}
-
 		}
 
 		outRow = rf.makeEmptyRow();
@@ -8828,7 +8784,10 @@ public final class	DataDictionaryImpl
 				// possibly see that the base row does not exist even if the
 				// index row did.  This mode is currently only used by
 				// TableNameInfo's call to hashAllTableDescriptorsByTableId,
-				// cf. DERBY-3678. A table's schema descriptor is attempted
+				// cf. DERBY-3678, and by getStatisticsDescriptors,
+                // cf. DERBY-4881.
+                //
+                // For the former call, a table's schema descriptor is attempted
 				// read, and if the base row for the schema has gone between
 				// reading the index and the base table, the table that needs
 				// this information has gone, too.  So, the table should not
@@ -8864,7 +8823,7 @@ public final class	DataDictionaryImpl
 			{
 				break;
 			}
-			else
+			else if (td != null)
 			{
 				list.add(td);
 			}



Mime
View raw message