2

I'm running SchemaSpy v6.1.0-SNAPSHOT on a fairly hefty Informix 12.10 schema, and I get the error "WARN - Failed to getImportedKeys The cursor has been previously released and is unavailable."

I know nothing about Java, but I've noticed a very similar error with Liquibase (also written in Java) and I wondered:

  1. whether anyone could advise me what causes this error and how I might avoid / work around it, given that I don't particularly want to learn Java :-)
  2. whether this is Informix-specific or is it also seen with other databases?

2 Answers2

3

The liquidbase stack trace you had in How do I use --logLevel in Liquibase actually gives us a hint, but took me a while to work out what is likely happening. There we can see liquibase using a cached resultset. Caching ResultSets (cursors) are dangerous as the Informix JDBC driver does not hold cursors over commits. So there is a good chance that the software opened a resultset (cursor) did some other operation which caused Informix/JDBC to close the cursor, then it tried to use the already closed cursor which causes your error.

There is an API to force JDBC to keep the cursors open: connection.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT)

But I'm guessing you don't have an ability to affect this inside these products to try it. Informix sadly does not allow this setting to happen in the URL. A feature that should be added :)

I tested against schemaspy against one of my databases (22 tables, 126 columns) with no issues with the latest Informix JDBC driver 4.10.JC12W1. The exact problem might be something that needs a reproduction for a support team to figure out for sure.

Brian Hughes
  • 683
  • 3
  • 8
  • 1
    Thanks, Brian. I've raised an RFE and I'm happy to provide a schema to support that you can use to repro. I've also asked one of my team who knows Java to look at the SchemaSpy code to see if he can add in your suggested fix. – Spokey Wheeler Mar 13 '19 at 10:53
  • @SpokeyWheeler yes, if you can get me or my team the schema I'd be happy to use that to try to track down the issue from our side. – Brian Hughes Mar 14 '19 at 14:34
1

I think I actually have the correct answer this time. I had to get some help tracking down this as it's a timing issue + bug in the driver.

The problem here is with some versions of the Informix JDBC driver. Quick fix is to upgrade to the latest 4.50.1 driver. It's out on maven.

<!-- https://mvnrepository.com/artifact/com.ibm.informix/jdbc -->
<dependency>
    <groupId>com.ibm.informix</groupId>
    <artifactId>jdbc</artifactId>
    <version>4.50.1</version>
</dependency>

In detail. The 4.10.X drivers introduced a statement cleaner thread that runs every 15 seconds and looks for resources that need to be closed as they have no more references and could be garbage collected. The problem, then compounds as a couple JDBC metdata calls incorrectly failed to close resources causing this cleaner thread to close resources in the middle of the work sometimes. Hence some people see it often, some never. You can work around it with 4.10.JC12 where we added a connection flag to disable the cleaner thread (IFMXCONNECTION_CLEANER_THREADS=0). Or the best option is to upgrade to the newest 4.50.1 driver which has this issue properly fixed.

Brian Hughes
  • 683
  • 3
  • 8