You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by fed <fu...@gmail.com> on 2012/06/30 23:24:51 UTC

Problem upgrading a derby database, ArrayIndexOutOfBoundsException on getIndexInfo()

Hi,

I posted time ago on this mailing list a similar question about an
upgrading problem but i never found a solution, now i think i have the
same problem with another derby database, i hope i can find a solution
this time.

I have a derby database 10.8.x and i use it with jdo/datanuclues.
I am trying to update it to 10.9 but after updating it the database
becomes unusable, it gives me an ArrayIndexOutOfBoundsException on
conn.getMetaData().getIndexInfo(... ).

I don't know very well what creates this error but i try to explain
some steps that i found that reproduce it.

1 - I acess the database with some client, for example Squirrel Sql (
squirrel sql uses the 10.9 driver version to access the db). It is not
need to execute any query or whatever just access the database and
close it.

2 - I update the database from 10.8 -> 10.9 using the upgrade = true
properties while connection to it and i close/shutdown the database.

3-  from datanucleus i have a tool that generate/update the schema of
the database, i run this tool and the operation fails.

>From derby.log logs i can see at the end of logs:

Sat Jun 30 22:41:55 CEST 2012
Thread[SwingWorker-pool-2-thread-2,5,main] (XID = 89554052),
(SESSIONID = 5), (DATABASE = db/rilevdata), (DRDAID = null), Executing
prepared statement: EXECUTE STATEMENT SYS."getTables" :End prepared
statement with 7 parameters begin parameter #1: % :end parameter begin
parameter #2: % :end parameter begin parameter #3:
FASCEMONTEORENEW_LISTA :end parameter begin parameter #4: T :end
parameter begin parameter #5: V :end parameter begin parameter #6: A
:end parameter begin parameter #7: S :end parameter
Sat Jun 30 22:41:55 CEST 2012
Thread[SwingWorker-pool-2-thread-2,5,main] (XID = 89554052),
(SESSIONID = 5), (DATABASE = db/rilevdata), (DRDAID = null), Begin
compiling prepared statement: EXECUTE STATEMENT SYS."getIndexInfo"
:End prepared statement
Sat Jun 30 22:41:55 CEST 2012
Thread[SwingWorker-pool-2-thread-2,5,main] (XID = 89554052),
(SESSIONID = 5), (DATABASE = db/rilevdata), (DRDAID = null), End
compiling prepared statement: EXECUTE STATEMENT SYS."getIndexInfo"
:End prepared statement
Sat Jun 30 22:41:55 CEST 2012
Thread[SwingWorker-pool-2-thread-2,5,main] (XID = 89554052),
(SESSIONID = 5), (DATABASE = db/rilevdata), (DRDAID = null), Cleanup
action starting
Sat Jun 30 22:41:55 CEST 2012
Thread[SwingWorker-pool-2-thread-2,5,main] (XID = 89554052),
(SESSIONID = 5), (DATABASE = db/rilevdata), (DRDAID = null), Failed
Statement is: null
java.lang.ArrayIndexOutOfBoundsException: 4
	at org.apache.derby.impl.sql.GenericParameterValueSet.initialize(Unknown
Source)
	at org.apache.derby.impl.sql.execute.BaseActivation.setupActivation(Unknown
Source)
	at org.apache.derby.impl.sql.GenericActivationHolder.<init>(Unknown Source)
	at org.apache.derby.impl.sql.GenericPreparedStatement.getActivation(Unknown
Source)
	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(Unknown Source)
	at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.<init>(Unknown Source)
	at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.<init>(Unknown Source)
	at org.apache.derby.impl.jdbc.EmbedPreparedStatement40.<init>(Unknown Source)
	at org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Unknown Source)
	at org.apache.derby.impl.jdbc.EmbedConnection.prepareMetaDataStatement(Unknown
Source)
	at org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.prepareSPS(Unknown Source)
	at org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.getPreparedQueryUsingSystemTables(Unknown
Source)
	at org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.getPreparedQuery(Unknown
Source)
	at org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.getPreparedQuery(Unknown
Source)
	at org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.doGetIndexInfo(Unknown
Source)
	at org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.getIndexInfo(Unknown
Source)
	at org.apache.commons.dbcp.DelegatingDatabaseMetaData.getIndexInfo(DelegatingDatabaseMetaData.java:327)
	at org.datanucleus.store.rdbms.schema.RDBMSSchemaHandler.getRDBMSTableIndexInfoForTable(RDBMSSchemaHandler.java:616)
	at org.datanucleus.store.rdbms.schema.RDBMSSchemaHandler.getRDBMSTableIndexInfoForTable(RDBMSSchemaHandler.java:585)
	at org.datanucleus.store.rdbms.schema.RDBMSSchemaHandler.getSchemaData(RDBMSSchemaHandler.java:202)
	at org.datanucleus.store.rdbms.table.TableImpl.getExistingCandidateKeys(TableImpl.java:1097)
	at org.datanucleus.store.rdbms.table.TableImpl.validateCandidateKeys(TableImpl.java:696)
	at org.datanucleus.store.rdbms.table.TableImpl.validateConstraints(TableImpl.java:398)
	at org.datanucleus.store.rdbms.table.ClassTable.validateConstraints(ClassTable.java:3234)
	at org.datanucleus.store.rdbms.RDBMSManager$ClassAdder.performTablesValidation(RDBMSManager.java:2827)
	at org.datanucleus.store.rdbms.RDBMSManager$ClassAdder.addClassTablesAndValidate(RDBMSManager.java:2557)
	at org.datanucleus.store.rdbms.RDBMSManager$ClassAdder.run(RDBMSManager.java:2203)
	at org.datanucleus.store.rdbms.AbstractSchemaTransaction.execute(AbstractSchemaTransaction.java:113)
	at org.datanucleus.store.rdbms.RDBMSManager.addClasses(RDBMSManager.java:987)
	at org.datanucleus.store.rdbms.SchemaTool.createSchema(SchemaTool.java:699)
	at presenze.gestione_update.GeneraSchemaUpdate.genera(GeneraSchemaUpdate.java:225)
	at presenze.gui.gestione_update.JFrameGestioneUpdate.updateSchema(JFrameGestioneUpdate.java:308)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.javabuilders.swing.handler.event.background.SwingBackgroundProcessingHandler$1.doInBackground(SwingBackgroundProcessingHandler.java:64)
	at javax.swing.SwingWorker$1.call(Unknown Source)
	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at javax.swing.SwingWorker.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)


and from now the database is unusable.


As test, with the database in this state if i run the code above i get
the same exception.

		try {
			Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
			Connection conn =
DriverManager.getConnection("jdbc:derby:db\\rilevdata", "sa", "sa");

			conn.getMetaData().getIndexInfo(null, "sa", "FASCEMONTEORENEW_LISTA
", false, false);
			
			conn.close();
		} catch (SQLException se) {
			
			log.error("exception", se);
			
			while (se != null) {
				System.out.println("SQLState=" + se.getSQLState() + se.getMessage());
				se.printStackTrace();
				se = se.getNextException();
			}
			

		}
	}


I have to say an import note: this happen only if in the first step i
access the db before upgrading it, and before running the tool from
datanucleus that update my schema,

If i skip the step 1 i can updgrade the db, update the schema and i
don't get the exception and the test code runs well.

But, to be clear,  these was just some steps that i found that cause
the problem;  the problem can happen in other different situations but
i was not able to find other steps to reproduce it.

Thanks for the help.

Regards

Re: Problem upgrading a derby database, ArrayIndexOutOfBoundsException on getIndexInfo()

Posted by Bryan Pendleton <bp...@gmail.com>.
On 06/30/2012 02:24 PM, fed wrote:
> I have a derby database 10.8.x and i use it with jdo/datanuclues.
> I am trying to update it to 10.9 but after updating it the database
> becomes unusable, it gives me an ArrayIndexOutOfBoundsException on
> conn.getMetaData().getIndexInfo(... ).

 From time to time, upgrade bugs such as this creep into Derby.

It sounds like you have made good progress on narrowing down a
reproduction scenario for this problem.

Getting the *exact* details for what reproduces the problem is
critical with these upgrade bugs. Derby has a very extensive
upgrade test suite, but there are an astonishing number of
combinations and sometimes something slips through.

It would be great if you can enter a JIRA issue describing the upgrade
problem that you are seeing, and include as much information as possible,
including all the information that you have in your email.

If you can describe the problem accurately enough that it can be
reproduced by somebody else, the odds of resolving it are very high.

thanks,

bryan