Return-Path: X-Original-To: apmail-db-derby-commits-archive@www.apache.org Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5D32D91EB for ; Mon, 26 Mar 2012 17:09:20 +0000 (UTC) Received: (qmail 39375 invoked by uid 500); 26 Mar 2012 17:09:20 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 39351 invoked by uid 500); 26 Mar 2012 17:09:20 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 39343 invoked by uid 99); 26 Mar 2012 17:09:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Mar 2012 17:09:20 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Mar 2012 17:09:18 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 6D1D2238897A; Mon, 26 Mar 2012 17:08:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1305451 - in /db/derby/code/branches/10.3/java: engine/org/apache/derby/impl/sql/compile/ engine/org/apache/derby/impl/sql/execute/ testing/org/apache/derbyTesting/functionTests/tests/lang/ testing/org/apache/derbyTesting/junit/ Date: Mon, 26 Mar 2012 17:08:58 -0000 To: derby-commits@db.apache.org From: mikem@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120326170858.6D1D2238897A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mikem Date: Mon Mar 26 17:08:57 2012 New Revision: 1305451 URL: http://svn.apache.org/viewvc?rev=1305451&view=rev Log: DERBY-4275: Query executions fail when compressing a table using SYSCS_UTIL.SYSCS_COMPRESS_TABLE backported changes #1142583 and #1160597 from trunk to 10.3 branch. Move invalidation of dependent statements until the system tables have been updated with information about the new conglomerates created by compression or truncation. This is to prevent that statements executing concurrently get recompiled too early and don't see the new conglomerates (and therefore fail on subsequent executions because they cannot find the old conglomerates). Fail in a controlled fashion (StandardException) if the conglomerate disappears while binding the FromBaseTable. This used to cause a NullPointerException. Did not backport the changes to TruncateTableTest. Truncate table functionality was released in 10.7, so changes did not apply to 10.5. Had to hand backport the CompressTableTest, removing tests for fixes not in 10.3. Added: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CompressTableTest.java - copied unchanged from r1305136, db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CompressTableTest.java Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java?rev=1305451&r1=1305450&r2=1305451&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java (original) +++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java Mon Mar 26 17:08:57 2012 @@ -2305,6 +2305,14 @@ public class FromBaseTable extends FromT tableDescriptor.getHeapConglomerateId() ); + // Bail out if the descriptor couldn't be found. The conglomerate + // probably doesn't exist anymore. + if (baseConglomerateDescriptor == null) { + throw StandardException.newException( + SQLState.STORE_CONGLOMERATE_DOES_NOT_EXIST, + new Long(tableDescriptor.getHeapConglomerateId())); + } + /* Build the 0-based array of base column names. */ columnNames = resultColumns.getColumnNames(); Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java?rev=1305451&r1=1305450&r2=1305451&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java (original) +++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java Mon Mar 26 17:08:57 2012 @@ -288,7 +288,7 @@ class AlterTableConstantAction extends D sd = getAndCheckSchemaDescriptor(dd, schemaId, "ALTER TABLE"); } - /* Prepare all dependents to invalidate. (This is there chance + /* Prepare all dependents to invalidate. (This is their chance * to say that they can't be invalidated. For example, an open * cursor referencing a table/view that the user is attempting to * alter.) If no one objects, then invalidate any dependent objects. @@ -1199,14 +1199,6 @@ class AlterTableConstantAction extends D TransactionController.MODE_TABLE, TransactionController.ISOLATION_SERIALIZABLE); - // invalidate any prepared statements that depended on this table - // (including this one), this fixes problem with threads that start up - // and block on our lock, but do not see they have to recompile their - // plan. We now invalidate earlier however they still might recompile - // using the old conglomerate id before we commit our DD changes. - // - dm.invalidateFor(td, DependencyManager.COMPRESS_TABLE, lcc); - rl = compressHeapCC.newRowLocationTemplate(); // Get the properties on the old heap @@ -1330,6 +1322,10 @@ class AlterTableConstantAction extends D // Update sys.sysconglomerates with new conglomerate # dd.updateConglomerateDescriptor(cd, newHeapConglom, tc); + // Now that the updated information is available in the system tables, + // we should invalidate all statements that use the old conglomerates + dm.invalidateFor(td, DependencyManager.COMPRESS_TABLE, lcc); + // Drop the old conglomerate tc.dropConglomerate(oldHeapConglom); cleanUp(); @@ -1419,15 +1415,6 @@ class AlterTableConstantAction extends D TransactionController.MODE_TABLE, TransactionController.ISOLATION_SERIALIZABLE); - // invalidate any prepared statements that - // depended on this table (including this one) - // bug 3653 has threads that start up and block on our lock, but do - // not see they have to recompile their plan. We now invalidate earlier - // however they still might recompile using the old conglomerate id before we - // commit our DD changes. - // - dm.invalidateFor(td, DependencyManager.TRUNCATE_TABLE, lcc); - rl = compressHeapCC.newRowLocationTemplate(); // Get the properties on the old heap compressHeapCC.getInternalTablePropertySet(properties); @@ -1512,6 +1499,11 @@ class AlterTableConstantAction extends D // Update sys.sysconglomerates with new conglomerate # dd.updateConglomerateDescriptor(cd, newHeapConglom, tc); + + // Now that the updated information is available in the system tables, + // we should invalidate all statements that use the old conglomerates + dm.invalidateFor(td, DependencyManager.TRUNCATE_TABLE, lcc); + // Drop the old conglomerate tc.dropConglomerate(oldHeapConglom); cleanUp(); Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java?rev=1305451&r1=1305450&r2=1305451&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java (original) +++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java Mon Mar 26 17:08:57 2012 @@ -61,6 +61,7 @@ public class _Suite extends BaseTestCase suite.addTest(org.apache.derbyTesting.functionTests.tests.memory.TriggerTests.suite()); suite.addTest(AnsiTrimTest.suite()); + suite.addTest(CompressTableTest.suite()); suite.addTest(CreateTableFromQueryTest.suite()); suite.addTest(DatabaseClassLoadingTest.suite()); suite.addTest(DynamicLikeOptimizationTest.suite()); Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java?rev=1305451&r1=1305450&r2=1305451&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java (original) +++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java Mon Mar 26 17:08:57 2012 @@ -531,11 +531,11 @@ public abstract class BaseTestCase * * @exception AssertionFailedError */ - public static void fail(String msg, Exception e) + public static void fail(String msg, Throwable t) throws AssertionFailedError { AssertionFailedError ae = new AssertionFailedError(msg); - ae.initCause(e); + ae.initCause(t); throw ae; }