You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Øyvind Harboe <oy...@zylin.com> on 2006/05/23 10:34:37 UTC

autoPkTableExists() is flaky w/MSAccess

As far as I can tell JdbcPkGenerator.autoPkTableExists() is flaky
w/MSAccess.

This is a problem when I try to run the JUnit tests as it leads to 
exceptions when JdbcPkGenerator.createAutoPk() tries to create the
AUTO_PK_SUPPORT table when the table already exists.

It is almost as if the md.getTables(null, null, "AUTO_PK_SUPPORT", null)
returns stale information.

Any bright insights?


-- 
Øyvind Harboe
http://www.zylin.com


Re: autoPkTableExists() is flaky w/MSAccess

Posted by Øyvind Harboe <oy...@zylin.com>.
On Tue, 2006-05-23 at 18:00 +0200, Tore Halset wrote:
> On May 23, 2006, at 10:34, Øyvind Harboe wrote:
> 
> > As far as I can tell JdbcPkGenerator.autoPkTableExists() is flaky
> > w/MSAccess.
> >
> > This is a problem when I try to run the JUnit tests as it leads to
> > exceptions when JdbcPkGenerator.createAutoPk() tries to create the
> > AUTO_PK_SUPPORT table when the table already exists.
> >
> > It is almost as if the md.getTables(null, null, "AUTO_PK_SUPPORT",  
> > null)
> > returns stale information.
> 
> If getTables() does not work, perhaps you could issue a "select *  
> from AUTO_PK_SUPPORT" in your own PkGenerator and look for  
> SQLExceptions?

I've had the chance to do some more testing and as long as I add
a 3 second pause before I run autoPkTableExists(), then the current
JdbcPkGenerator implementation of autoPkTableExists() runs fine. 

protected boolean autoPkTableExists(DataNode node) throws SQLException {
        /* FIX!!!!! why is a 3 second pause necessary here???? */
        try 
        {
            Thread.sleep(3000);
        }
        catch (InterruptedException e1) {
            e1.printStackTrace();
        }
        return super.autoPkTableExists(node);
}

-- 
Øyvind Harboe
http://www.zylin.com


Re: autoPkTableExists() is flaky w/MSAccess

Posted by Øyvind Harboe <oy...@zylin.com>.
On Wed, 2006-05-24 at 08:38 -0400, Kevin Menard wrote:
> On Wed, 24 May 2006 02:13:13 -0400, Øyvind Harboe  
> <oy...@zylin.com> wrote:
> 
> 
> > Could it be that I'm getting bitten by connection pooling?
> > One connection is used to create the table, another(stale) is used to
> > check for the presence of AUTO_PK_SUPPORT.
> 
> Sorry if this might be asking the obvious, but do you have the problem  
> with a connection pool of size 1?

Yes, same result. I set a breakpoint in PoolManager (init +
setMaxConnections) and verified that minConnections and maxConnections
both were 1.


-- 
Øyvind Harboe
http://www.zylin.com


Re: autoPkTableExists() is flaky w/MSAccess

Posted by Kevin Menard <km...@servprise.com>.
On Wed, 24 May 2006 02:13:13 -0400, Øyvind Harboe  
<oy...@zylin.com> wrote:


> Could it be that I'm getting bitten by connection pooling?
> One connection is used to create the table, another(stale) is used to
> check for the presence of AUTO_PK_SUPPORT.

Sorry if this might be asking the obvious, but do you have the problem  
with a connection pool of size 1?

-- 
Kevin



Re: autoPkTableExists() is flaky w/MSAccess

Posted by Øyvind Harboe <oy...@zylin.com>.
On Tue, 2006-05-23 at 18:00 +0200, Tore Halset wrote:
> On May 23, 2006, at 10:34, Øyvind Harboe wrote:
> 
> > As far as I can tell JdbcPkGenerator.autoPkTableExists() is flaky
> > w/MSAccess.
> >
> > This is a problem when I try to run the JUnit tests as it leads to
> > exceptions when JdbcPkGenerator.createAutoPk() tries to create the
> > AUTO_PK_SUPPORT table when the table already exists.
> >
> > It is almost as if the md.getTables(null, null, "AUTO_PK_SUPPORT",  
> > null)
> > returns stale information.
> 
> If getTables() does not work, perhaps you could issue a "select *  
> from AUTO_PK_SUPPORT" in your own PkGenerator and look for  
> SQLExceptions?

Good suggestion. I tried it and got closer to the core of the
problem.

It appears that it takes a couple of seconds from a table is created
until it is possible to reliably check for the existence of
AUTO_PK_SUPPORT. My data is weak, but I have not yet observed 
the problem if I add a 3000ms pause before I check for the presence of
AUTO_PK_SUPPORT.

A wild guess:

Could it be that I'm getting bitten by connection pooling?
One connection is used to create the table, another(stale) is used to
check for the presence of AUTO_PK_SUPPORT. 


-- 
Øyvind Harboe
http://www.zylin.com


Re: autoPkTableExists() is flaky w/MSAccess

Posted by Tore Halset <ha...@pvv.ntnu.no>.
On May 23, 2006, at 10:34, Øyvind Harboe wrote:

> As far as I can tell JdbcPkGenerator.autoPkTableExists() is flaky
> w/MSAccess.
>
> This is a problem when I try to run the JUnit tests as it leads to
> exceptions when JdbcPkGenerator.createAutoPk() tries to create the
> AUTO_PK_SUPPORT table when the table already exists.
>
> It is almost as if the md.getTables(null, null, "AUTO_PK_SUPPORT",  
> null)
> returns stale information.

If getTables() does not work, perhaps you could issue a "select *  
from AUTO_PK_SUPPORT" in your own PkGenerator and look for  
SQLExceptions?

  - Tore.