You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Doc: ParameterMetaData.getParameterType performance on Oracle 12c [SPR-16139] #20687
After upgrading from Spring 4.3 to 5.0.1 the NamedParameterJdbcTemplate.batchUpdate call results in an exception ORA-01000: maximum open cursors exceeded when using with Oracle 12c.
The batchUpdate is updating batches of 250 records.
The applications code hasn't changed in method where exception is being thrown.
There has been quite a bit of JDBC baseline upgrading in Spring Framework 5.0, so maybe this is a side effect... Any insight (or even guess) into where the different behavior might be caused?
I couldn't find anything else causing the issue, rollback did the job. I rolled back spring-jdbc alone leaving other spring libraries at version 5.0.1.
I am using ojdbc7.jar driver for Oracle 12c version 12.1.0.2
I have a suspicion that this is the same effect as with #19196... a workaround which we removed in 5.0 as part of our JDBC baseline upgrade.
You could try setting spring.jdbc.getParameterType.ignore=true, either as a system property or in a spring.properties file in the root of the classpath. If this is known to help, we may consider reintroducing the workaround to 5.0's streamlined variant of StatementCreatorUtils.setNull.
That said, see my comment in #19196: Recent Oracle 12c drivers should not expose that cursor leak anymore. If an Oracle driver upgrade helps, that would also be great to know!
I have replaced the existing driver with ojdbc8.jar version 12.2.0.1 which fixed the problem. I was no longer getting maximum open cursors exception and the process completed successfully.
The only problem is the performance. The batch update operation used to take 0.5 seconds for 250 records but now it takes 6 seconds instead. After rolling back to spring-jdbc 4.3.10.RELEASE the timings where back to normal - 0.5 second (using the new Oracle driver).
Overall the new JDBC driver does address the issue of the exception but there is a performance problem now.
BTW, I've created #20763 inspired by your source code example (and a similar case in our reference documentation). Such manual collection adaptation shouldn't be necessary. I've added overloaded methods to SqlParameterSourceUtils, allowing for the following concise code:
public int[] saveBatchOutputs(final String updateSql, final List<Map<String, Object>> batchValuesList) {
return namedParameterJdbcTemplate.batchUpdate(updateSql, SqlParameterSourceUtils.createBatch(batchValuesList));
}
Activity
spring-projects-issues commentedon Oct 31, 2017
Juergen Hoeller commented
There has been quite a bit of JDBC baseline upgrading in Spring Framework 5.0, so maybe this is a side effect... Any insight (or even guess) into where the different behavior might be caused?
spring-projects-issues commentedon Nov 1, 2017
Adam Sojka commented
I have just verified that rolling back spring-jdbc to 4.3.10 resolved the issue.
spring-projects-issues commentedon Nov 2, 2017
Adam Sojka commented
I couldn't find anything else causing the issue, rollback did the job. I rolled back spring-jdbc alone leaving other spring libraries at version 5.0.1.
I am using ojdbc7.jar driver for Oracle 12c version 12.1.0.2
spring-projects-issues commentedon Nov 14, 2017
Juergen Hoeller commented
I have a suspicion that this is the same effect as with #19196... a workaround which we removed in 5.0 as part of our JDBC baseline upgrade.
You could try setting
spring.jdbc.getParameterType.ignore=true, either as a system property or in aspring.propertiesfile in the root of the classpath. If this is known to help, we may consider reintroducing the workaround to 5.0's streamlined variant ofStatementCreatorUtils.setNull.That said, see my comment in #19196: Recent Oracle 12c drivers should not expose that cursor leak anymore. If an Oracle driver upgrade helps, that would also be great to know!
spring-projects-issues commentedon Nov 15, 2017
Adam Sojka commented
I have replaced the existing driver with ojdbc8.jar version 12.2.0.1 which fixed the problem. I was no longer getting maximum open cursors exception and the process completed successfully.
The only problem is the performance. The batch update operation used to take 0.5 seconds for 250 records but now it takes 6 seconds instead. After rolling back to spring-jdbc 4.3.10.RELEASE the timings where back to normal - 0.5 second (using the new Oracle driver).
Overall the new JDBC driver does address the issue of the exception but there is a performance problem now.
spring-projects-issues commentedon Nov 15, 2017
Juergen Hoeller commented
Thanks for the feedback, that's good to know!
For the performance part of the problem, does it help to set
spring.jdbc.getParameterType.ignore=trueas suggested above?spring-projects-issues commentedon Nov 16, 2017
Adam Sojka commented
Yes, after adding spring.properties with spring.jdbc.getParameterType.ignore=true the performance issue was resolved.
In Summary to resolve the issue one need to:
spring-projects-issues commentedon Nov 16, 2017
Juergen Hoeller commented
Alright, let's turn this into a documentation task then, putting specific notes for Oracle 12c into our reference documentation.
spring-projects-issues commentedon Nov 18, 2017
Juergen Hoeller commented
BTW, I've created #20763 inspired by your source code example (and a similar case in our reference documentation). Such manual collection adaptation shouldn't be necessary. I've added overloaded methods to
SqlParameterSourceUtils, allowing for the following concise code:spring-projects-issues commentedon Nov 19, 2017
Adam Sojka commented
Juergen, Thank you very much for resolving the issue.