db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1354015 - /db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java
Date Tue, 26 Jun 2012 13:46:15 GMT
Author: kahatlen
Date: Tue Jun 26 13:46:14 2012
New Revision: 1354015

URL: http://svn.apache.org/viewvc?rev=1354015&view=rev
Log:
DERBY-5358: SYSCS_COMPRESS_TABLE failed with conglomerate not found exception

Make TableDescriptor.heapConglomNumber volatile to ensure that
getHeapConglomerateId() never sees a partly initialized value.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java?rev=1354015&r1=1354014&r2=1354015&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java
Tue Jun 26 13:46:14 2012
@@ -142,7 +142,26 @@ public class TableDescriptor extends Tup
 	String							tableName;
 	UUID							oid;
 	int								tableType;
-	long							heapConglomNumber = -1;
+
+    /**
+     * <p>
+     * The id of the heap conglomerate for the table described by this
+     * instance. The value -1 means it's uninitialized, in which case it
+     * will be initialized lazily when {@link #getHeapConglomerateId()} is
+     * called.
+     * </p>
+     *
+     * <p>
+     * It is declared volatile to ensure that concurrent callers of
+     * {@code getHeapConglomerateId()} while {@code heapConglomNumber} is
+     * uninitialized, will either see the value -1 or the fully initialized
+     * conglomerate number, and never see a partially initialized value
+     * (as was the case in DERBY-5358 because reads/writes of a long field are
+     * not guaranteed to be atomic unless the field is declared volatile).
+     * </p>
+     */
+    private volatile long           heapConglomNumber = -1;
+
     ColumnDescriptorList            columnDescriptorList;
 	ConglomerateDescriptorList		conglomerateDescriptorList;
 	ConstraintDescriptorList		constraintDescriptorList;
@@ -336,8 +355,6 @@ public class TableDescriptor extends Tup
 	public long getHeapConglomerateId()
 			throws StandardException
 	{
-		DataDictionary dd = getDataDictionary();
-
 		ConglomerateDescriptor cd = null;
 
 		/* If we've already cached the heap conglomerate number, then



Mime
View raw message