db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r1031623 - in /db/derby/code/branches/10.6: ./ java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
Date Fri, 05 Nov 2010 15:25:10 GMT
Author: kristwaa
Date: Fri Nov  5 15:25:09 2010
New Revision: 1031623

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

Merged fix from trunk (r1030043).

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

Propchange: db/derby/code/branches/10.6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov  5 15:25:09 2010
@@ -1,2 +1,2 @@
-/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,958163,958522,958555,958618,958939,959550,962716,963206,963705,964115,965647,967304,980684,986689,986834,987539,989099,990292,997325,998170,999119,1002291,1002682,1002853,1021426,1025795
+/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,958163,958522,958555,958618,958939,959550,962716,963206,963705,964115,965647,967304,980684,986689,986834,987539,989099,990292,997325,998170,999119,1002291,1002682,1002853,1021426,1025795,1030043
 /db/derby/docs/trunk:954344

Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?rev=1031623&r1=1031622&r2=1031623&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
(original)
+++ db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
Fri Nov  5 15:25:09 2010
@@ -1655,6 +1655,7 @@ public final class	DataDictionaryImpl
 						(TupleDescriptor) null,
 						(List) null,
 						false,
+                        TransactionController.ISOLATION_REPEATABLE_READ,
 						tc);
 	}
 
@@ -4925,9 +4926,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
 	{
@@ -4939,13 +4947,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;
 	}
@@ -8453,63 +8464,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);
 	}
 
 	/**
@@ -8583,7 +8547,6 @@ public final class	DataDictionaryImpl
 		CatalogRowFactory		rf = ti.getCatalogRowFactory();
 		ConglomerateController	heapCC;
 		ExecIndexRow	  		indexRow1;
-		ExecIndexRow			indexTemplateRow;
 		ExecRow 				outRow;
 		RowLocation				baseRowLocation;
 		ScanController			scanController;
@@ -8595,13 +8558,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();
@@ -8714,7 +8670,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
@@ -8750,7 +8709,7 @@ public final class	DataDictionaryImpl
 			{
 				break;
 			}
-			else
+			else if (td != null)
 			{
 				list.add(td);
 			}
@@ -9438,7 +9397,6 @@ public final class	DataDictionaryImpl
 	{
 		TabInfoImpl ti = getNonCoreTI(SYSSEQUENCES_CATALOG_NUM);
 		ExecIndexRow keyRow = null;
-		ExecRow row;
 
 		keyRow = (ExecIndexRow)exFactory.getIndexableRow(1);
 		keyRow.setColumn(1, new SQLChar( sequenceIDstring ) );
@@ -9446,7 +9404,7 @@ public final class	DataDictionaryImpl
 		rowLocation[ 0 ] = ti.getRowLocation( tc, keyRow, SYSSEQUENCESRowFactory.SYSSEQUENCES_INDEX1_ID
);
         
         sequenceDescriptor[ 0 ] = (SequenceDescriptor)
-            getDescriptorViaIndexMinion
+            getDescriptorViaIndex
             (
              SYSSEQUENCESRowFactory.SYSSEQUENCES_INDEX1_ID,
              keyRow,



Mime
View raw message