db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1063960 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/store/raw/data/ engine/org/apache/derby/loc/ shared/org/apache/derby/shared/common/reference/ testing/org/apache/derbyTesting/unitTests/store/
Date Thu, 27 Jan 2011 02:14:05 GMT
Author: dag
Date: Thu Jan 27 02:14:05 2011
New Revision: 1063960

URL: http://svn.apache.org/viewvc?rev=1063960&view=rev
Log:
DERBY-4982 Retrying after interrupts in store pops a bug in derbyall/storeall/storeunit/T_RawStoreFactory
in some cases

Patch derby-4982c. Makes the sane and insane behavior of double patch attempt detection the
same: throw DATA_DOUBLE_LATCH_INTERNAL_ERROR.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BasePage.java
    db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_Util.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BasePage.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BasePage.java?rev=1063960&r1=1063959&r2=1063960&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BasePage.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BasePage.java Thu
Jan 27 02:14:05 2011
@@ -1671,13 +1671,14 @@ abstract class BasePage implements Page,
 					return;
 				}
 
-				// just deadlock out if a transaction tries to double latch the
-				// page while not in abort
-
-				if (SanityManager.DEBUG) {
-					SanityManager.THROWASSERT("Attempted to latch page twice");
-				}
-
+                // A transaction tries to double latch the page while not in
+                // abort: if we let it wait, it would hang forever, so it's
+                // better to throw an exception. This should never occur unless
+                // the code is wrong.  If it still does, we'd better tear down
+                // the connection just in case, so the error has session level
+                // severity;
+                throw StandardException.newException(
+                    SQLState.DATA_DOUBLE_LATCH_INTERNAL_ERROR, identity);
 			}
 
 			while (owner != null) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml?rev=1063960&r1=1063959&r2=1063960&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml Thu Jan 27 02:14:05
2011
@@ -5516,6 +5516,11 @@ ln=lower-case two-letter ISO-639 languag
                 <arg>className</arg>
             </msg>
 
+            <msg>
+                <name>XSDAO.S</name>
+                <text>Internal error: page {0} attempted latched twice.</text>
+                <arg>pageNumber</arg>
+            </msg>
         </family>
 
 

Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java?rev=1063960&r1=1063959&r2=1063960&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
(original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
Thu Jan 27 02:14:05 2011
@@ -483,6 +483,7 @@ public interface SQLState {
 	String DATA_UNEXPECTED_OVERFLOW_PAGE                        = "XSDAL.S";
     String DATA_SQLDATA_READ_INSTANTIATION_EXCEPTION            = "XSDAM.S";
     String DATA_SQLDATA_READ_ILLEGAL_ACCESS_EXCEPTION           = "XSDAN.S";
+    String DATA_DOUBLE_LATCH_INTERNAL_ERROR                     = "XSDAO.S";
 
 	/*
 	** RawStore - Data.Generic transaction exceptions

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_Util.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_Util.java?rev=1063960&r1=1063959&r2=1063960&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_Util.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_Util.java Thu
Jan 27 02:14:05 2011
@@ -1142,48 +1142,15 @@ public class T_Util
 	 */
 	public void t_checkGetLatchedPage(ContainerHandle c, long pageNumber)
 			throws StandardException, T_Fail {
-		// we expect to hang in getPage() so make sure we are interrupted
-		final Thread me = Thread.currentThread();
-		Runnable r = new Runnable() {
-				public void run() {
-					try {
-						Thread.sleep(2000);
-					} catch (InterruptedException e) { }
-					me.interrupt();
-				}
-			};
-		Thread interrupter = new Thread(r);
-		if (!SanityManager.DEBUG) {
-			// don't run the interrupter thread in sane builds, since getPage()
-			// will throw an assert error instead of hanging (DERBY-2635)
-			interrupter.start();
-		}
 
 		try {
 			Page p = c.getPage(pageNumber);
 			throw T_Fail.testFailMsg("got latched page");
 		} catch (StandardException se) {
-			// expect thread interrupted exception in insane builds
-			if (SanityManager.DEBUG || !se.getMessageId().equals("08000")) {
+            if (!"XSDAO".equals(se.getSQLState())) {
 				throw se;
 			}
-		} catch (RuntimeException e) {
-			// When running in sane mode, an AssertFailure will be thrown if we
-			// try to double latch a page. The AssertFailure class is not
-			// available in insane jars, so we cannot reference the class
-			// directly.
-			if (!(SanityManager.DEBUG &&
-				  e.getClass().getName().endsWith(".sanity.AssertFailure") &&
-				  e.getMessage().endsWith("Attempted to latch page twice"))) {
-				throw e;
-			}
 		}
-
-		try {
-			if (interrupter.isAlive()) {
-				interrupter.join();
-			}
-		} catch (InterruptedException ie) { }
 	}
 
 	/**



Mime
View raw message