db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r1307946 - in /db/derby/code/branches/10.6/java: engine/org/apache/derby/impl/store/raw/data/ engine/org/apache/derby/impl/store/raw/xact/ testing/org/apache/derbyTesting/functionTests/tests/store/ testing/org/apache/derbyTesting/junit/
Date Sun, 01 Apr 2012 00:03:33 GMT
Author: mikem
Date: Sun Apr  1 00:03:33 2012
New Revision: 1307946

URL: http://svn.apache.org/viewvc?rev=1307946&view=rev
Log:
DERBY-5624 System can run out of stack space while processing DropOnCommit requests.

backporting change #1307679 from 10.8 to 10.6 branch.

Taking care of cleanup after a commit is handled by notifying all "Observers"
that an event has taken place that they might want to act on and cleanup. In
the added test case this is triggered by off line commit which effectively
drops and recreates the base table and all of its indexes after loading the
data into them.

Sometimes these Observers may execute work which adds to the Observer queue,
and that queue can "miss" them in the first pass through.

A previous fix for this problem added a recursive call to notifyObservers in
the place that could cause this addition of observers. This recursive call
was causing stack problems when the number of Observers became large. For
the checked in test case this was 1000 indexes on 1000 columns of the table.
For other users I believe the cause was a by product of sorts on large disk
based sorts for multi-gigabyte tables and indexes. 2 users were reporting
similar failed stacks for failing compresses of large tables, and one was
able to take this fix to their environment and then successfully run the
compress.

The fix was to remove the recursion and instead loop at the outermost point
until there were no Observers.

backport to largedata suite did not go smoothly, so just put the test into
the store suite.

Only run the testDERBY_5624 on windows until linux issue resolved.

Currently on linux with 1024 file descriptors per user this test fails.


Added:
    db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby5624Test.java
      - copied unchanged from r1307832, db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby5624Test.java
Modified:
    db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/raw/data/DropOnCommit.java
    db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/raw/xact/Xact.java
    db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
    db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java

Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/raw/data/DropOnCommit.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/raw/data/DropOnCommit.java?rev=1307946&r1=1307945&r2=1307946&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/raw/data/DropOnCommit.java
(original)
+++ db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/raw/data/DropOnCommit.java
Sun Apr  1 00:03:33 2012
@@ -98,14 +98,6 @@ public class DropOnCommit extends Contai
 			}
 
 			obj.deleteObserver(this);
-
-            // DERBY-3993
-            // make sure any observer that may have been added by either
-            // dropContainer() or dropStreamContainer() is also handled.
-            // The calling notifyObservers() call from Xact.doComplete()
-            // may not "see" new observers added during processing of the
-            // initial observer list.
-            xact.notifyObservers(arg);
 		}
 	}
 }

Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/raw/xact/Xact.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/raw/xact/Xact.java?rev=1307946&r1=1307945&r2=1307946&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/raw/xact/Xact.java
(original)
+++ db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/raw/xact/Xact.java
Sun Apr  1 00:03:33 2012
@@ -1960,20 +1960,25 @@ public class Xact extends RawTransaction
 		if (savePoints != null)
 			savePoints.removeAllElements();
 
-		// notify any of our observers that we are completing.
-		notifyObservers(commitOrAbort);
+        do
+        {
+            // notify any of our observers that we are completing.
+            notifyObservers(commitOrAbort);
 
-		checkObserverException();
+            checkObserverException();
 
-		if (SanityManager.DEBUG) 
-        {
-			if (countObservers() != 0)
-            {
-                SanityManager.THROWASSERT(
-                    "There should be 0 observers, but we still have "
-					+ countObservers() + " observers.");
-            }
-		}
+            // DERBY-3993
+            // make sure any observer that may have been added by either
+            // dropContainer() or dropStreamContainer() is also handled.
+            // The calling notifyObservers() call from Xact.doComplete()
+            // may not "see" new observers added during processing of the
+            // initial observer list.  So loop until notifyObservers()
+            // call causes countObservers() to go to 0.  This should only
+            // loop if one of the observers adds to the list as part of
+            // the notify.  Even then depending on ordering the added
+            // observer may be picked up in the first try.
+
+        } while (countObservers() > 0);
 	}
 
 	private void checkObserverException() throws StandardException {

Modified: db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java?rev=1307946&r1=1307945&r2=1307946&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
(original)
+++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
Sun Apr  1 00:03:33 2012
@@ -56,6 +56,7 @@ public class _Suite extends BaseTestCase
         suite.addTest(ClassLoaderBootTest.suite());
         suite.addTest(StreamingColumnTest.suite());
         suite.addTest(Derby3625Test.suite());
+        suite.addTest(Derby5624Test.suite());
         suite.addTest(Derby151Test.suite());
         suite.addTest(Derby4676Test.suite());
         suite.addTest(BootLockTest.suite());

Modified: db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java?rev=1307946&r1=1307945&r2=1307946&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
(original)
+++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
Sun Apr  1 00:03:33 2012
@@ -558,6 +558,94 @@ public abstract class BaseTestCase
         return getSystemProperty("com.ibm.oti.vm.exe") != null;
     }
 
+    public static final boolean isSunJVM() {
+        String vendor = getSystemProperty("java.vendor");
+        return "Sun Microsystems Inc.".equals(vendor) ||
+                "Oracle Corporation".equals(vendor);
+    }
+    
+    public static final boolean isPlatform(String osName)  {
+
+        return getSystemProperty("os.name").equals(osName);
+    }
+
+    /**
+     * Determine if platform is a Windows variant.
+     * <p>
+     * Return true if platform is a windows platform.  Just looks for
+     * os.name starting with "Windows".  The os.name property
+     * can have at least the following values (there are probably more):
+     *
+     * AIX
+     * Digital Unix
+     * FreeBSD
+     * HP UX
+     * Irix
+     * Linux
+     * Mac OS
+     * Mac OS X
+     * MPE/iX
+     * Netware 4.11
+     * OS/2
+     * Solaris
+     * Windows 2000
+     * Windows 95
+     * Windows 98
+     * Windows NT
+     * Windows Vista
+     * Windows XP
+     * <p>
+     *
+     * @return true if running on a Windows platform.
+     **/
+    public static final boolean isWindowsPlatform() {
+        return getSystemProperty("os.name").startsWith("Windows");
+    }
+    
+    /**
+     * Check if this is java 5
+     * @return true if java.version system property starts with 1.5
+     */
+    public static final boolean isJava5() {
+        return getSystemProperty("java.version").startsWith("1.5");
+    }
+   
+    /**
+     * Returns the major version of the class specification version supported
+     * by the running JVM.
+     * <ul>
+     *  <li>48 = Java 1.4</li>
+     *  <li>49 = Java 1.5</li>
+     *  <li>50 = Java 1.6</li>
+     *  <li>51 = Java 1.7</li>
+     * </ul>
+     *
+     * @return Major version of class version specification, i.e. 49 for 49.0,
+     *      or -1 if the version can't be obtained for some reason.
+     */
+    public static int getClassVersionMajor() {
+        String tmp = getSystemProperty("java.class.version");
+        if (tmp == null) {
+            println("VM doesn't have property java.class.version");
+            return -1;
+        }
+        // Is String.split safe to use by now?
+        int dot = tmp.indexOf('.');
+        int major = -1;
+        try {
+            major = Integer.parseInt(tmp.substring(0, dot));
+        } catch (NumberFormatException nfe) {
+            // Ignore, return -1.
+        }
+        return major;
+    }
+
+
+    public static final boolean isIBMJVM() {
+        return ("IBM Corporation".equals(
+                getSystemProperty("java.vendor")));
+    }
+    
    /**
     * Reads output from a process and returns it as a string.
     * This will block until the process terminates.



Mime
View raw message