db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Øystein Grøvlen (JIRA) <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-230) "Schema already exists" when creating a table
Date Wed, 20 Apr 2005 08:48:25 GMT
     [ http://issues.apache.org/jira/browse/DERBY-230?page=comments#action_63265 ]
Øystein Grøvlen commented on DERBY-230:

As far as I can understand, the problem is in DDLConstantAction.getSchemaDescriptorForCreate()
which first tries to
get a SchemaDescriptor and if none exists will create one.  What probably happens is that
a thread detects that the schema does not exist, but when it tries to create the SchemaDescriptor,
another thread has already done that.  There is at least two possible ways to fix this:

1. Make getSchemaDescriptorForCreate() synchronized.  (I have tested this and it solves the

2. Ignore the "Schema already exists" exception from executeConstantAction.  The subsequent
getSchemaDescriptor will then get the SchemaDescriptor created by the other thread.

> "Schema already exists" when creating a table
> ---------------------------------------------
>          Key: DERBY-230
>          URL: http://issues.apache.org/jira/browse/DERBY-230
>      Project: Derby
>         Type: Bug
>   Components: SQL
>     Versions:,,,
>     Reporter: Øystein Grøvlen
>  Attachments: Main.java
> When running a multithreaded program where several threads in parallell create tables
in a schema that is not explicitly created, one often get the following exception:
> ERROR X0Y68: Schema 'TESTSCHEMA' already exists.
>     at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:322)
>     at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.duplicateDescriptorException(DataDictionaryImpl.java:1512)
>     at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.addDescriptorNow(DataDictionaryImpl.java:1496)
>     at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.addDescriptor(DataDictionaryImpl.java:1478)
>     at org.apache.derby.impl.sql.execute.CreateSchemaConstantAction.executeConstantAction(CreateSchemaConstantAction.java:147)
>     at org.apache.derby.impl.sql.execute.DDLConstantAction.getSchemaDescriptorForCreate(Unknown
>     at org.apache.derby.impl.sql.execute.CreateTableConstantAction.executeConstantAction(CreateTableConstantAction.java:213)
>     at org.apache.derby.impl.sql.execute.MiscResultSet.open(MiscResultSet.java:56)
>     at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:366)
>     at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1108)
>     at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:517)
>     at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:475)
>     at derbytest.Main$CreateTable.run(Main.java:42)
>     at java.lang.Thread.run(Thread.java:595)
> A program that reproduces this bug will be attached.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message