db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r743820 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClobReclamationTest.java
Date Thu, 12 Feb 2009 18:11:02 GMT
Author: kmarsden
Date: Thu Feb 12 18:11:02 2009
New Revision: 743820

URL: http://svn.apache.org/viewvc?rev=743820&view=rev
Log:
DERBY-4054 ClobReclamationTest.xtestMultiThreadedUpdateTableLocking() demonstrates the problem.
 This does not fix the issue.


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClobReclamationTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClobReclamationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClobReclamationTest.java?rev=743820&r1=743819&r2=743820&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClobReclamationTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClobReclamationTest.java
Thu Feb 12 18:11:02 2009
@@ -61,7 +61,7 @@
      * @throws SQLException
      * @throws InterruptedException
      */
-    public void testMultiThreadedUpdate() throws SQLException,
+    public void testMultiThreadedUpdate(final boolean lockTable) throws SQLException,
             InterruptedException {
         // need to do a getConnection or we get a
         // junit assertion that driver is not registered.
@@ -74,8 +74,9 @@
                 public void run() {
                     try {
                         Connection conn = openDefaultConnection();
+                        conn.setAutoCommit(false);
                         ClobReclamationTest.fiveHundredUpdates(conn,
-                                updateString, key);
+                                updateString, key, lockTable);                      
                     } catch (SQLException e) {
                         fail(e.getMessage());
                     }
@@ -100,16 +101,42 @@
     }
 
     private static void fiveHundredUpdates(Connection conn,
-            String updateString, int key) throws SQLException {
+            String updateString, int key, boolean lockTable) throws SQLException {
         PreparedStatement ps = conn
                 .prepareStatement("UPDATE CLOBTAB SET C = ? WHERE I = ?");
         for (int i = 0; i < 500; i++) {
+            if (lockTable) {
+                Statement s = conn.createStatement();
+                s.executeUpdate("LOCK TABLE CLOBTAB IN EXCLUSIVE MODE");
+             }
             ps.setString(1, updateString);
             ps.setInt(2, key);
             ps.executeUpdate();
+            conn.commit();
         }
     }
 
+    /**
+     * Test multithreaded clob update using standard row locking
+     * @throws SQLException
+     * @throws InterruptedException
+     */
+    public void testMultiThreadedUpdateRowLocking() throws SQLException, InterruptedException
{
+        testMultiThreadedUpdate(false);
+    }
+    
+    /**
+     * Test multithreaded clob update but get an exclusive lock on the
+     * table for each update. We can't enable this teset until DERBY-4054 
+     * is fixed.
+     * 
+     * @throws SQLException
+     * @throws InterruptedException
+     */
+    public void xtestMultiThreadedUpdateTableLocking() throws SQLException, InterruptedException
{
+        testMultiThreadedUpdate(true);
+    }
+    
     public static Test suite() {
 
         Properties sysProps = new Properties();



Mime
View raw message