db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oystein.Grov...@Sun.COM (Øystein Grøvlen)
Subject Re: [jira] Commented: (DERBY-230) "Schema already exists" when creating a table
Date Thu, 21 Apr 2005 12:20:47 GMT
>>>>> "ØG(" == Øystein Grøvlen (JIRA) <derby-dev@db.apache.org> writes:

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

    ØG(> 1. Make getSchemaDescriptorForCreate() synchronized.  (I have
    ØG(> tested this and it solves the problem).

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

Being new to Derby, I am not quite sure which alternative should be
preferred here.  Making the method synchronized is the simplest
alternative, but I see that no other method of DLLConstantAction is

For the second alternative, I looked around the code without finding
any similar case where a SQLException is ignored.  Hence, I am
wondering whether it is kosher to do it this way.  Is there any Derby
policy that can guide me in choosing between the alternatives?

It would be nice if the Developer's Guide contained an example of how
to handle specific exceptions (e.g., I want to ignore "Table does not
exist" exceptions for a "drop table" statement, but not other
exceptions).  Another thing that I am not able to find in the manuals,
is a complete list of possible exceptions.


View raw message