db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-6314) Upgrade from 10.10 fails with ClassCastException
Date Fri, 23 Aug 2013 15:02:51 GMT

    [ https://issues.apache.org/jira/browse/DERBY-6314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13748608#comment-13748608
] 

Knut Anders Hatlen commented on DERBY-6314:
-------------------------------------------

Thanks for running those experiments, Rick. I think the serialization problem happens because
the GenericStoredPreparedStatements in SYS.SYSSTATEMENTS.CONSTANTSTATE now may contain references
to ExecRowBuilder instances, which are Serializable and not Formatable. And since the TypeDescriptorImpl
instances in question live inside ExecRowBuilder, they will be stored using the Serializable
logic instead of the Formatable logic they are intended to be stored with. In your experiment,
with a different column, ExecRowBuilder wasn't there to confuse things, so Formatable logic
was used all the way. The Formatable logic doesn't care about the serialVersionUID, so the
deserialization was successful in that experiment.

I think I'm now able to answer the questions from one of my earlier comments:

> Is it correct to store these objects with Java serialization instead of using Derby's
Formatable logic?

No, Formatable objects should have been stored with Formatable logic. ExecRowBuilder probably
has to be changed to Formatable for the contained TypeDescriptorImpl instances to be stored
correctly.

> TypeDescriptorImpl's serialVersionUID has changed many times before. Why does upgrade
only fail now?
> TypeDescriptorImpl's serialVersionUID did not change between 10.9 and 10.10. Still, upgrade
from 10.9 to trunk does not fail. What changed in 10.10?

ExecRowBuilder was not introduced until 10.10 (DERBY-6003), so we never attempted to store
TypeDescriptorImpl using Serializable logic before 10.10. The Formatable logic doesn't care
about serialVersionUID.

> It looks like it's deserialization of the CONSTANTSTATE column in SYS.SYSSTATEMENTS that
fails. That is, the stored prepared statement for a meta-data query. I recall that we at some
point changed the upgrade logic to prevent it from deserializing that column, because the
format of the stored plan is not guaranteed to be stable. Why is it attempting to read it
now?

Those fixes only affected stored trigger plans. Metadata plans are still read during upgrade.
                
> Upgrade from 10.10 fails with ClassCastException
> ------------------------------------------------
>
>                 Key: DERBY-6314
>                 URL: https://issues.apache.org/jira/browse/DERBY-6314
>             Project: Derby
>          Issue Type: Bug
>          Components: Services
>    Affects Versions: 10.11.0.0
>            Reporter: Knut Anders Hatlen
>
> I noticed that after running the SignatureChecker tool on a database with version 10.10.1.1,
I could not boot it with trunk (neither hard nor soft upgrade worked).
> To reproduce, create a database and run SignatureChecker with 10.10:
> $ java -jar /code/derby/oldreleases/10.10.1.1/derbyrun.jar SignatureChecker 'jdbc:derby:db;create=true'
> Then, try to boot that database with trunk:
> $ java -Dderby.database.allowPreReleaseUpgrade=true -jar /code/derby/trunk/jars/sane/derbyrun.jar
SignatureChecker 'jdbc:derby:db'             
> java.lang.reflect.InvocationTargetException
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:606)
> 	at org.apache.derby.tools.SignatureChecker.getJ2SEConnection(SignatureChecker.java:445)
> 	at org.apache.derby.tools.SignatureChecker.execute(SignatureChecker.java:140)
> 	at org.apache.derby.tools.SignatureChecker.main(SignatureChecker.java:121)
> 	at org.apache.derby.iapi.tools.run.main(run.java:61)
> Caused by: java.sql.SQLException: Failed to start database 'db' with class loader sun.misc.Launcher$AppClassLoader@7e820d53,
see the next exception for details.
> 	at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:103)
> 	at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:137)
> 	at org.apache.derby.impl.jdbc.Util.seeNextException(Util.java:310)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(EmbedConnection.java:2841)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.<init>(EmbedConnection.java:404)
> 	at org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(InternalDriver.java:628)
> 	at org.apache.derby.jdbc.InternalDriver.connect(InternalDriver.java:282)
> 	at org.apache.derby.jdbc.InternalDriver.connect(InternalDriver.java:913)
> 	at org.apache.derby.jdbc.AutoloadedDriver.connect(AutoloadedDriver.java:147)
> 	at java.sql.DriverManager.getConnection(DriverManager.java:571)
> 	at java.sql.DriverManager.getConnection(DriverManager.java:233)
> 	... 8 more
> Caused by: java.sql.SQLException: Failed to start database 'db' with class loader sun.misc.Launcher$AppClassLoader@7e820d53,
see the next exception for details.
> 	at org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory.java:141)
> 	at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:73)
> 	... 18 more
> Caused by: java.sql.SQLException: Exception during restore of a serializable or SQLData
object of class 
> 	at org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory.java:141)
> 	at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:73)
> 	at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:288)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(EmbedConnection.java:2835)
> 	... 15 more
> Caused by: ERROR XSDA8: Exception during restore of a serializable or SQLData object
of class 
> 	at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:265)
> 	at org.apache.derby.impl.store.raw.data.StoredPage.readRecordFromArray(StoredPage.java:5827)
> 	at org.apache.derby.impl.store.raw.data.StoredPage.restoreRecordFromSlot(StoredPage.java:1514)
> 	at org.apache.derby.impl.store.raw.data.BasePage.fetchFromSlot(BasePage.java:441)
> 	at org.apache.derby.impl.store.raw.data.CachedPage.fetchFromSlot(CachedPage.java:53)
> 	at org.apache.derby.impl.store.access.conglomerate.GenericConglomerateController.fetch(GenericConglomerateController.java:299)
> 	at org.apache.derby.impl.sql.catalog.TabInfoImpl.deleteRows(TabInfoImpl.java:725)
> 	at org.apache.derby.impl.sql.catalog.TabInfoImpl.deleteRow(TabInfoImpl.java:570)
> 	at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.dropSPSDescriptor(DataDictionaryImpl.java:4673)
> 	at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.dropSPSDescriptor(DataDictionaryImpl.java:4647)
> 	at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.dropJDBCMetadataSPSes(DataDictionaryImpl.java:14121)
> 	at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.updateMetadataSPSes(DataDictionaryImpl.java:14135)
> 	at org.apache.derby.impl.sql.catalog.DD_Version.handleMinorRevisionChange(DD_Version.java:539)
> 	at org.apache.derby.impl.sql.catalog.DD_Version.upgradeIfNeeded(DD_Version.java:238)
> 	at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.loadDictionaryTables(DataDictionaryImpl.java:7984)
> 	at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.boot(DataDictionaryImpl.java:818)
> 	at org.apache.derby.impl.services.monitor.BaseMonitor.boot(BaseMonitor.java:1991)
> 	at org.apache.derby.impl.services.monitor.TopService.bootModule(TopService.java:334)
> 	at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(BaseMonitor.java:541)
> 	at org.apache.derby.impl.services.monitor.FileMonitor.startModule(FileMonitor.java:44)
> 	at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Monitor.java:423)
> 	at org.apache.derby.impl.db.BasicDatabase.boot(BasicDatabase.java:196)
> 	at org.apache.derby.impl.services.monitor.BaseMonitor.boot(BaseMonitor.java:1991)
> 	at org.apache.derby.impl.services.monitor.TopService.bootModule(TopService.java:334)
> 	at org.apache.derby.impl.services.monitor.BaseMonitor.bootService(BaseMonitor.java:1819)
> 	at org.apache.derby.impl.services.monitor.BaseMonitor.startProviderService(BaseMonitor.java:1685)
> 	at org.apache.derby.impl.services.monitor.BaseMonitor.findProviderAndStartService(BaseMonitor.java:1569)
> 	at org.apache.derby.impl.services.monitor.BaseMonitor.startPersistentService(BaseMonitor.java:988)
> 	at org.apache.derby.iapi.services.monitor.Monitor.startPersistentService(Monitor.java:546)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(EmbedConnection.java:2802)
> 	... 15 more
> Caused by: java.io.StreamCorruptedException: java.lang.ClassCastException: java.io.ObjectInputStream
cannot be cast to org.apache.derby.iapi.services.io.ErrorInfo
> 	at org.apache.derby.iapi.services.io.FormatIdInputStream.readObject(FormatIdInputStream.java:139)
> 	at org.apache.derby.iapi.services.io.ArrayUtil.readArrayItems(ArrayUtil.java:180)
> 	at org.apache.derby.impl.sql.GenericStorablePreparedStatement.readExternal(GenericStorablePreparedStatement.java:232)
> 	at org.apache.derby.iapi.services.io.FormatIdInputStream.readObject(FormatIdInputStream.java:125)
> 	at org.apache.derby.iapi.types.UserType.readExternal(UserType.java:299)
> 	at org.apache.derby.impl.store.raw.data.StoredPage.readRecordFromArray(StoredPage.java:5684)
> 	... 43 more
> Caused by: java.lang.ClassCastException: java.io.ObjectInputStream cannot be cast to
org.apache.derby.iapi.services.io.ErrorInfo
> 	at org.apache.derby.iapi.services.io.FormatIdInputStream.readObject(FormatIdInputStream.java:97)
> 	... 48 more
> Could not get a connection.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message