From derby-commits-return-940-apmail-db-derby-commits-archive=db.apache.org@db.apache.org Sat Jun 04 18:03:31 2005 Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 59738 invoked from network); 4 Jun 2005 18:03:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Jun 2005 18:03:31 -0000 Received: (qmail 61430 invoked by uid 500); 4 Jun 2005 18:03:31 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 61396 invoked by uid 500); 4 Jun 2005 18:03:31 -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 61382 invoked by uid 500); 4 Jun 2005 18:03:31 -0000 Delivered-To: apmail-incubator-derby-cvs@incubator.apache.org Received: (qmail 61375 invoked by uid 99); 4 Jun 2005 18:03:31 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Sat, 04 Jun 2005 11:03:30 -0700 Received: (qmail 59723 invoked by uid 65534); 4 Jun 2005 18:03:29 -0000 Message-ID: <20050604180329.59722.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r180009 - in /incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/ConcurrentImplicitCreateSchema.out tests/lang/ConcurrentImplicitCreateSchema.java Date: Sat, 04 Jun 2005 18:03:28 -0000 To: derby-cvs@incubator.apache.org From: bandaram@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: bandaram Date: Sat Jun 4 11:03:27 2005 New Revision: 180009 URL: http://svn.apache.org/viewcvs?rev=3D180009&view=3Drev Log: Derby-230: Submit missed test files in the previous checkin for this bug. (= 179834) Submitted by Oystein Grovlen.(Oystein.Grovlen@Sun.COM) Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functio= nTests/master/ConcurrentImplicitCreateSchema.out (with props) incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functio= nTests/tests/lang/ConcurrentImplicitCreateSchema.java (with props) Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/func= tionTests/master/ConcurrentImplicitCreateSchema.out URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/= org/apache/derbyTesting/functionTests/master/ConcurrentImplicitCreateSchema= .out?rev=3D180009&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functio= nTests/master/ConcurrentImplicitCreateSchema.out (added) +++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functio= nTests/master/ConcurrentImplicitCreateSchema.out Sat Jun 4 11:03:27 2005 @@ -0,0 +1,3 @@ +Test ConcurrentImplicitCreateSchema starting +Closed connection +Test ConcurrentImplicitCreateSchema PASSED Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting= /functionTests/master/ConcurrentImplicitCreateSchema.out ---------------------------------------------------------------------------= --- svn:eol-style =3D native Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/func= tionTests/tests/lang/ConcurrentImplicitCreateSchema.java URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/= org/apache/derbyTesting/functionTests/tests/lang/ConcurrentImplicitCreateSc= hema.java?rev=3D180009&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functio= nTests/tests/lang/ConcurrentImplicitCreateSchema.java (added) +++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functio= nTests/tests/lang/ConcurrentImplicitCreateSchema.java Sat Jun 4 11:03:27 2= 005 @@ -0,0 +1,193 @@ +/* + + Derby - Class org.apache.derbyTesting.functionTests.tests.lang. Concurr= entImplicitCreateSchema.java + + Copyright 2005 The Apache Software Foundation or its licensors, as appl= icable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + */ + +package org.apache.derbyTesting.functionTests.tests.lang; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; + +import org.apache.derby.tools.ij; + +/** + * Test for several threads creating tables in the same originally + * non-existing schema. This will cause an implicit creation of the + * schema. The test was created for the fix of JIRA issue DERBY-230 + * where an error occurred if two threads try to create the schema in + * parallel. + *=20 + * @author oystein.grovlen@sun.com + */ + +public class ConcurrentImplicitCreateSchema +{ + =20 + /** + * Runnable that will create and drop table. + */ + class CreateTable implements Runnable=20 + { + /** Id of the thread running this instance */ + private int myId; + /** Which schema to use */ + private int schemaId; + /** Database connection for this thread */ + private Connection conn =3D null; + /** Test object. Used to inform about failures. */ + private ConcurrentImplicitCreateSchema test; + + CreateTable(int id, int schemaId,=20 + ConcurrentImplicitCreateSchema test)=20 + throws SQLException, IllegalAccessException,=20 + ClassNotFoundException, InstantiationException + { + this.myId =3D id; + this.schemaId =3D schemaId; + this.test =3D test;=20 + + // Open a connection for this thread + conn =3D ij.startJBMS(); + conn.setAutoCommit(false); + } + =20 + public void run() =20 + { + try { + Statement s =3D conn.createStatement(); + s.execute("create table testschema" + schemaId + ".testtab= "=20 + + myId + "(num int, addr varchar(40))"); + s.execute("drop table testschema" + schemaId + ".testtab"=20 + + myId); + } catch (SQLException e) { + test.failed(e); + }=20 + =20 + // We should close the transaction regardless of outcome=20 + // Otherwise, other threads may wait on transactional=20 + // locks until this transaction times out. + try { + conn.commit(); + conn.close(); + } catch (SQLException e) { + test.failed(e); + } + // System.out.println("Thread " + myId + " complete= d=2E"); + } + } + =20 + /**=20 + * Outcome of test. =20 + * Will be set to false if any failure is detected. + */ + boolean passed =3D true; + + public static void main(String[] args) + { + new ConcurrentImplicitCreateSchema().go(args); + } + + void go(String[] args) + { + System.out.println("Test ConcurrentImplicitCreateSchema starting"); + + try { + // Load the JDBC Driver class + // use the ij utility to read the property file and + // make the initial connection. + ij.getPropertyArg(args); + Connection conn =3D ij.startJBMS(); + + conn.setAutoCommit(true); + + // Drop the schemas we will be using in case they exist. + // This will ensure that they are implicitly created by this t= est + Statement s =3D conn.createStatement(); + + // Number of schemas to use. An equal number of threads + // will operate on each schema. + final int NSCHEMAS =3D 1; + + for (int i=3D0; i < NSCHEMAS; ++i) { + try { + s.execute("drop schema testschema" + i + " restrict"); + } catch (SQLException e) { + if (e.getSQLState().equals("42Y07")) { + // IGNORE. Schema did not exist. That is our targe= t=2E + } else { + throw e; + } + } + } + + // Number of threads to run. =20 + final int NTHREADS =3D 100; =20 + + // Create threads + Thread[] threads =3D new Thread[NTHREADS]; + for (int i=3D0; i