Upgrade task throws "cached plan must not change result type"

Hi,

I meet this error on some installations of my addon, could someone give me a hint about how to resolve it ?

Basically, I’ve created upgrade tasks as the development of my addon progressed, and it has always worked. However, if I install in UPM on a new Confluence 6.7, five upgrade tasks and the sixth throws the following exception, just when calling ao.migrate().

Have you ever met this issue?

[INFO]  -- url: /confluence/rest/plugins/1.0/ | referer: http://confluence.local:1990/confluence/plugins/servlet/upm | traceId: 0cff52fa7325f445 | userName: admin
[INFO] java.lang.RuntimeException: Could not read fields for table AO_32F7CE_AOREQUIREMENT
[INFO] 	at net.java.ao.schema.helper.DatabaseMetaDataReaderImpl.getFields(DatabaseMetaDataReaderImpl.java:139)
[INFO] 	at net.java.ao.schema.ddl.SchemaReader.readFields(SchemaReader.java:126)
[INFO] 	at net.java.ao.schema.ddl.SchemaReader.readTable(SchemaReader.java:110)
[INFO] 	at net.java.ao.schema.ddl.SchemaReader.access$000(SchemaReader.java:62)
[INFO] 	at net.java.ao.schema.ddl.SchemaReader$1.apply(SchemaReader.java:99)
[INFO] 	at net.java.ao.schema.ddl.SchemaReader$1.apply(SchemaReader.java:97)
...
[INFO] 	at net.java.ao.schema.ddl.SchemaReader.readSchema(SchemaReader.java:97)
...
[INFO] 	at net.java.ao.schema.SchemaGenerator.generateImpl(SchemaGenerator.java:107)
[INFO] 	at net.java.ao.schema.SchemaGenerator.migrate(SchemaGenerator.java:84)
[INFO] 	at net.java.ao.EntityManager.migrate(EntityManager.java:128)
[INFO] 	at com.atlassian.activeobjects.internal.EntityManagedActiveObjects.migrate(EntityManagedActiveObjects.java:51)
[INFO] 	at com.playsql.requirementyogi.ao.V35MarkOrphanDependenciesUpgradeTask.upgrade(V35MarkOrphanDependenciesUpgradeTask.java:39)
[INFO] 	at com.atlassian.activeobjects.internal.ActiveObjectUpgradeManagerImpl$1.doInTransaction(ActiveObjectUpgradeManagerImpl.java:68)
...
[INFO] 	at com.atlassian.activeobjects.internal.ActiveObjectUpgradeManagerImpl.upgrade(ActiveObjectUpgradeManagerImpl.java:64)
[INFO] Caused by: org.postgresql.util.PSQLException: ERROR: cached plan must not change result type
[INFO] 	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2476)
[INFO] 	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2189)
[INFO] 	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:300)
[INFO] 	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:428)
[INFO] 	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:354)
[INFO] 	at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:169)
[INFO] 	at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:117)
[INFO] 	at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:379)
[INFO] 	at net.java.ao.schema.helper.DatabaseMetaDataReaderImpl.getResultSetMetaData(DatabaseMetaDataReaderImpl.java:265)
[INFO] 	at net.java.ao.schema.helper.DatabaseMetaDataReaderImpl.getFields(DatabaseMetaDataReaderImpl.java:89)
[INFO] 	... 81 more
[INFO] 2018-01-23 14:20:12,234 WARN [active-objects-init-system tenant-0] [confluence.impl.hibernate.ConfluenceHibernateTransactionManager] doRollback Performing rollback. Transactions:
[INFO]   ->[PluginReadWriteTx]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT (Session #1704265965)
[INFO]  -- url: /confluence/rest/plugins/1.0/ | referer: http://confluence.local:1990/confluence/plugins/servlet/upm | traceId: 0cff52fa7325f445 | userName: admin
1 Like

Hi Play SQL, you’re not alone, I’m here. See, it’s still possible to find help here, this community is still full of experts.

I’ve tried your problem and it seems like it could be due to calling ao.migrate() in each upgrade task. See, if you only call it once across all upgrade tasks, you don’t have this problem.

Of course that wouldn’t work if you have several schema changes. But who cares! Why would you change your database schema anyway? Seriously I wouldn’t recommend changing your schema much. Stick with only adding columns or tables, so you can afford to only call ao.migrate() once across all your upgrade tasks and hope that AO won’t betray you AGAIN.

It’s not like 80% of your support load is caused by bugs in ActiveObjects, is it?

To my experience confluence gives the developer enough workaround ways (good and bad ones) to solve a specific problem.

In your case, I personally would export data, manipulate, create new schemas, import and move on cause things go fast and sometimes you just need to do your job in one or another way.